/**
 * @function RIA Client
 * @encode utf-8
 * @copyright (C) lijun; Rex@小网
 * @file RIAClient.js
 * @author lijun; Rex@小网
 * @version 1.9.6
 * @QQ群 70704280
 * @URL http://code.google.com/p/ria-client/
 * @date 2008-11-26
 */
var Browser = (function()
{
    var userAgent = navigator.userAgent.toLowerCase();
    var env = null;
    return (env = userAgent.match(/msie ([\d.]+)/)) ? {type:"MSIE", version:env[1]} :
    (env = userAgent.match(/firefox\/([\d.]+)/)) ? {type:"FireFox", version:env[1]} :
    (env = userAgent.match(/opera.([\d.]+)/)) ? {type:"Opera", version:env[1]} :
    (env = userAgent.match(/version\/([\d.]+).*safari/)) ? {type:"Safari", version:env[1]} :
    (env = userAgent.match(/chrome\/([\d.]+)/)) ? {type:"Chrome", version:env[1]} :
    {type:"Unknown", version:0};
})();
/**
 * 兼容FireFox浏览器事件句柄
 */
if (window.Event && "MSIE" != Browser.type)
{
    function SearchEvent()
    {
        var func=SearchEvent.caller;
        while(func!=null)
        {
           var arg=func.arguments[0];
           if(arg)
           {
              if(String(arg.constructor).indexOf('Event') > -1)
              {
                  return arg;
              }
           }
           func=func.caller;
	    }
	    return null;
    }
    window.constructor.prototype.__defineGetter__
    (
        "event",
        function()
        {
           return SearchEvent()
        }
    );

    Event.prototype.__defineSetter__
    (
        "returnValue",
        function(bool)
        {
            if (!bool)
            {
                this.preventDefault();
            }
            return bool;
        }
    );

    Event.prototype.__defineSetter__
    (
        "cancelBubble",
        function(bool)
        {
            if (bool)
            {
                this.stopPropagation();
            }
            return bool;
        }
    );

    Event.prototype.__defineGetter__
    (
        "clientX",
        function()
        {
            return this.pageX;
        }
    );

    Event.prototype.__defineGetter__
    (
        "clientY",
        function()
        {
            return this.pageY;
        }
    );

    Event.prototype.__defineGetter__
    (
        "keyCode",
        function()
        {
            return this.which;
        }
    );

    Event.prototype.__defineGetter__
    (
        "button",
        function()
        {
            return this.which;
        }
    );

    Event.prototype.__defineGetter__
    (
        "srcElement",
        function()
        {
            var n = this.target;
            while (n.nodeType != 1)
            {
                n = n.parentNode;
            }
            return n;
        }
    );

    Event.prototype.__defineGetter__
    (
        "offsetX",
        function()
        {
            return this.layerX;
        }
    );

    Event.prototype.__defineGetter__
    (
        "offsetY",
        function()
        {
            return this.layerY;
        }
    );

    Event.prototype.attachEvent = function(type, handler)
    {
        this.addEventListener(type.substring(2), handler, true);
    };

    Event.prototype.detachEvent = function(type, handler)
    {
        this.removeEventListener(type.substring(2), handler, true);
    };

    window.constructor.prototype.attachEvent = function(type, handler)
    {
        this.addEventListener(type.substring(2), handler, true);
    };

    window.constructor.prototype.detachEvent = function(type, handler)
    {
        this.removeEventListener(type.substring(2), handler, true);
    };

    document.constructor.prototype.attachEvent = function(type, handler)
    {
        this.addEventListener(type.substring(2), handler, true);
    };

    document.constructor.prototype.detachEvent = function(type, handler)
    {
        this.removeEventListener(type.substring(2), handler, true);
    };

    Element.prototype.attachEvent = function(type, handler)
    {
        this.addEventListener(type.substring(2), handler, true);
    };

    Element.prototype.detachEvent = function(type, handler)
    {
        this.removeEventListener(type.substring(2), handler, true);
    };

    HTMLElement.prototype.attachEvent = function(type, handler)
    {
        this.addEventListener(type.substring(2), handler, true);
    };

    HTMLElement.prototype.detachEvent = function(type, handler)
    {
        this.removeEventListener(type.substring(2), handler, true);
    };
    CSSStyleSheet.prototype.addRule = function(selector, rule, index)
    {
        var _rule = selector + "{" + rule + "}";
        this.insertRule(_rule, index);
    };
    CSSStyleSheet.prototype.removeRule = function(index)
    {
        this.deleteRule(index);
    };
}/* end if (兼容FireFox浏览器事件句柄) */

/**
 * 扩展String对象
 * 匹配以prefix开头的字符串
 * @param prefix 匹配字符串
 * @param offset 偏移值
 * @return 是否匹配 true/false
 */
String.prototype.startsWith = function(prefix, offset)
{
    offset = typeof(offset) == "number" ? offset : 0;
    if (this.length >= (prefix.length + offset))
    {
        return (this.substr(offset, prefix.length) == prefix);
    }
    else
    {
        return false;
    }
};

/**
 * 扩展String对象
 * 匹配以suffix结尾的字符串
 * @param suffix 匹配字符串
 * @return 是否匹配 true/false
 */
String.prototype.endsWith = function(suffix)
{
    if (this.length >= suffix.length)
    {
        return (this.substr((this.length - suffix.length), suffix.length) == suffix);
    }
    else
    {
        return false;
    }
};

/**
 * 扩展String对象
 * 替换所有相匹配的字符或字符串
 * @param regexp 匹配表达式
 * @param replacement 替换字符串
 * @return 替换后的字符串,如果没有找到匹配返回原字符串
 */
String.prototype.replaceAll = function(regexp, replacement)
{
    return this.replace(new RegExp(regexp, "gm"), replacement);
};

/**
 * 扩展String对象
 * 替换匹配表达式第一次出现的内容
 * @param regexp 匹配表达式
 * @param replacement 替换字符串
 * @return 替换后的字符串,如果没有找到匹配返回原字符串
 */
String.prototype.replaceFirst = function(regexp, replacement)
{
    var group = new RegExp("("+ regexp + ")", "gm").exec(this);
    if (null != group)
    {
        return this.substring(0, group.index)
            .concat(replacement)
            .concat(this.substring(group.index+group[1].length));
    }
    else
    {
        return this;
    }
};

/**
 * 扩展String对象
 * 去空字符
 * @return 去空后的字符串
 */
String.prototype.trim = function()
{
    return this.replace(/[\s ]/gmi, "");
};

/**
 * 扩展String对象
 * 去左空字符
 * @return 去空后的字符串
 */
String.prototype.leftTrim = function()
{
  return this.replace(/^[\s ]/gmi, "");
};

/**
 * 扩展String对象
 * 去右空字符
 * @return 去空后的字符串
 */
String.prototype.rightTrim = function()
{
  return this.replace(/[\s ]$/gmi, "");
};

/**
 * 扩展String对象
 * 去两边空字符
 * @return 去空后的字符串
 */
String.prototype.bothTrim = function()
{
  return (this.leftTrim()).rightTrim();
};

/**
 * 扩展String对象
 * 返回实际长度,区分中英文
 * @return 字符串长度
 */
String.prototype.size = function()
{
    return this.replace(/[^\u0000-\u00FF]/gmi, "**").length;
};

/**
 * 扩展Object对象
 * 设置一个属性
 * @param key 属性名
 * @param value 属性值
 */
Object.prototype.put = function(key, value)
{
    this[key] = value;
};

/**
 * 扩展Object对象
 * 获取一个属性
 * @param key 属性名
 * @return 返回key所对应的属性,如果没有返回null
 */
Object.prototype.get = function(key)
{
    return this[key] || null;
};

/**
 * 扩展Object对象
 * 删除一个属性
 * @param key 属性名
 */
Object.prototype.remove = function(key)
{
    if(typeof(this[key]) != "undefined")
        delete this[key];
};

var RIAClient = {
    /**
     * 获取对象类型
     * @param obj 对象
     * @return 对象类型
     */
    getType : function(obj)
    {
       return typeof(obj);
    },
    /**
     * 根据ID获取元素对象
     * @param id 元素ID或对象
     * @return 元素对象,如果没有匹配返回null
     */
    $E : function(id, parent)
    {
        var pNode = parent || document;
        var ret = null;
        switch(this.getType(id))
        {
            case "string":
                ret = pNode.getElementById(id);
            break;
            case "object":
                if(id.nodeType && 1 == id.nodeType)
                {
                    ret = id;
                }
            break;
        }
        return ret;
    },
    /**
     * 根据标签名获取元素集
     * @param tagName 标签名
     * @return 元素集
     */
    $T : function(tagName)
    {
        return document.getElementsByTagName(tagName);
    },
    /**
     * 建立一个新的元素
     * @param tag
     * @return 新建立的元素
     */
    $C : function(tag)
    {
        return document.createElement(tag);
    },
    /**
     * 建立一个新的文本节点
     * @param text 文本内容
     * @return 新建立的文本节点
     */
    $X : function(text)
    {
        return document.createTextNode(text);
    },
    /**
     * 追加一个新的节点
     * @param cNode 要追加的节点
     * @param pNode 父节点
     * @return 追加后的节点
     */
    $A : function(cNode, pNode)
    {
        var p = pNode || document.body || document.documentElement;
        return p.appendChild(cNode);
    },
    /**
     * 删除一个节点
     * @param cNode 要删除的节点
     * @param pNode 父节点
     * @return 删除后的节点
     */
    $D : function(cNode, pNode)
    {
        var p = pNode || document.body || document.documentElement;
        return p.removeChild(cNode);
    },
    /**
     * 替换一个节点
     * @param nNode 新节点
     * @param oNode 参考节点
     * @return 替换后的节点,如果参考节点没有父级节点则返回null
     */
    $R : function(nNode, oNode)
    {
        var p = oNode.parentNode;
        if(null != p)
        {
            return p.replaceChild(nNode, oNode);
        }
        return null;
    },
    /**
     * 插入一个新的节点
     * @param newNode 新节点
     * @param refNode 参考节点
     * @return 插入新节点后的节点, 如果没参考节点没有父级节点则返回null
     */
    $I : function(newNode, refNode)
    {
        var p = refNode.parentNode;
        if(null != p)
        {
            return  p.insertBefore(newNode, refNode);
        }
        return null;
    },
    /**
     * 获取浏览器版本号及类型
     * @member browser 浏览器类型
     * @member version 浏览器版本
     * @return 浏览器的类型及版本号
     */
    getBrowserInfo : function()
    {
        return Browser;
    },
    /**
     * 获取文档大小
     * @member width 文档宽
     * @member height 文档高
     * @return 返回文档的宽和高
     */
    getDocumentSize : function()
    {
        var doc = document.documentElement || document.body;
        var viewport = this.getViewportSize();
        var _w = Math.max(doc.scrollWidth, viewport.width);
        var _h = Math.max(doc.scrollHeight, viewport.height);
        return {width:_w, height:_h};
    },
    /**
     * 获取视窗大小
     * @member width 视窗宽
     * @member height 视窗高
     * @return 返回视窗的宽和高
     */
    getViewportSize : function()
    {
        var doc = document.documentElement || document.body;
        var _w = window.innerWidth || doc.clientWidth;
        var _h = window.innerHeight || doc.clientHeight;
        return {width:_w, height:_h};
    },
    /**
     * 获取滚动条的位置
     * @member left 左偏移值
     * @member top 上偏移值
     * @return 返回滚动条的左和上的偏移值
     */
    getScrollPosition : function()
    {
        var doc = document.documentElement || document.body;
        var _l = window.pageXOffset || doc.scrollLeft;
        var _t = window.pageYOffset || doc.scrollTop;
        return {left:_l, top:_t};
    },
    /**
     * 获取屏幕大小
     * @member width 屏幕宽
     * @member height 屏幕高
     * @member offsetTop 顶部偏移值
     * @member offsetLeft 左侧偏移值
     * @return 返回屏幕大小及偏移值
     */
    getScreenSize : function()
    {
        var _w = window.screen.width;
        var _h = window.screen.height;
        var _t = window.screenTop || window.screenX;
        var _l = window.screenLeft || window.screenY;
        return {width:_w, height:_h, offsetTop:_t, offsetLeft:_l};
    },
    /**
     * 从外部引用的css或style标签中获取css属性
     * @param selector 选择符
     * @param attr 属性
     * @return css属性,没有匹配返回null
     */
    getOuterStyle : function(selector, attr)
    {
        var stylesheet = document.styleSheets;
        var size = stylesheet.length;
        var sheet = null;
        var rules = null;
        var ruleSize = 0;
        var rule = null;
        for(var i = 0; i < size; i++)
        {
            sheet = stylesheet.item(i);
            rules = sheet.rules || sheet.cssRules;
            ruleSize = rules.length;
            for(var j = 0; j < ruleSize; j++)
            {
                rule = rules[j];
                if(!rule.selectorText)continue;
                if (selector == rule.selectorText)
                {
                    return rule.style[attr];
                }
            }
        }
        return null;
    },
    /**
     * 从外部引用的css或style标签中设置css属性
     * @param selector 选择符
     * @param attr 属性
     * @param value 属性值
     * @return css属性,没有匹配返回null
     */
    setOuterStyle : function(selector, attr, value)
    {
        var stylesheet = document.styleSheets;
        var size = stylesheet.length;
        var sheet = null;
        var rules = null;
        var ruleSize = 0;
        var rule = null;

        outer:
        for(var i = 0; i < size; i++)
        {
            sheet = stylesheet.item(i);
            rules = sheet.rules || sheet.cssRules;
            ruleSize = rules.length;
            inner:
            for(var j = 0; j < ruleSize; j++)
            {
                rule = rules[j];
                if(!rule.selectorText)continue;
                if (selector == rule.selectorText)
                {
                    rule.style[attr] = value;
                    break outer;
                }
            }
        }
    },
    /**
     * 动态设置样式
     * @param cssTexts 样式集
     * @return DOM
     */
    dynamicStyle : function(cssTexts)
    {
        var style = this.$C("style");
        var id = "dynamic_style_" + this.getTimeStamp();
        style.type = "text/css";
        style.rel = "stylesheet";
        style.setAttribute("id", id);
        this.$A(style,this.$T("head")[0]);
        if("MSIE" == this.getBrowserInfo().type)
        {
            style.styleSheet.cssText = cssTexts.join("");
        }
        else
        {
            for(var i = 0; i < cssTexts.length; i++)
            {
                style.sheet.insertRule(cssTexts[i], i);
            }
        }
        return style;
    },
    /**
     * 获取时间戳
     * @return  时间戳
     */
    getTimeStamp : function()
    {
        return (new Date()).getTime();
    },
    /**
     * 拖动
     * @param 动态参数, 为拖动对象的ID名
     */
    drag : function()
    {
        var args = arguments;
        var size = args.length;
        var ris = this;
        for (var i = 0; i < size; i++)
        {
            var tar = this.$E(args[i]);
            var l = window.event.clientX - tar.offsetLeft;
            var t = window.event.clientY - tar.offsetTop;
            var isDrag = true;

            tar.style.cursor = "default";
            document.attachEvent("onmousemove", function ()
            {
                var innerArgs = args;
                var size = innerArgs.length;
                if (isDrag)
                {
                    for (var j = 0; j < size; j++)
                    {
                        var innerTar = ris.$E(innerArgs[j]);
                        innerTar.style.left = Math.max(window.event.clientX - l, 0) + "px";
                        innerTar.style.top = Math.max(window.event.clientY - t, 0) + "px";
                    }
                    return event.returnValue = !(event.cancelBubble = true);
                }
            });
            document.attachEvent("onmouseup", function ()
            {
                isDrag = false;
            });
        }
    },
    /**
     * 编码
     * @param str 需要编码的字符串
     * @return 编码后的字符串
     */
    encode : function(str)
    {
        return encodeURIComponent(str);
    },
    /**
     * 解码
     * @param str 需要解码的字符串
     * @return 解码后的字符串
     */
    decode : function(str)
    {
        return decodeURIComponent(str);
    },
    /**
     * 设置cookie
     * @param key 键名
     * @param value 键值
     * @param domain 域
     * @param expires 过期时间
     * @throws 参数错误
     */
    setCookie : function(key, value, domain, expires)
    {
        var args = arguments;
        var size = args.length;
        var exp = 0;
        switch (size)
        {
            case 2:
                document.cookie = key + "=" + this.encode(value) + "; path=/;";
                break;
            case 3:
                document.cookie = key + "=" + this.encode(value) + "; path=/; domain=" + domain;
                break;
            case 4:
                exp = new Date((new Date().getTime() + expires * 3600000)).toGMTString();
                document.cookie = key + "=" + this.encode(value) + "; path=/; domain="+domain+"; expires=" + exp;
                break;
            default:
                throw new Error("设置cookie时参数错误！");
        }
    },
    /**
     * 获取cookie值
     * @param key 键名
     * @return cookie值,如果没有返回null
     */
    getCookie : function(key)
    {
        var cookie = document.cookie;
        var items = cookie.split("; ");
        var item = [];
        var size = items.length;
        for (var i = 0; i < size; i++)
        {
            item = items[i].split("=");
            if(key == item[0] && item.length == 2)
            {
                return this.decode(item[1]);
            }
        }
        return null;
    },
    /**
     * 获取URL参数
     * @param key 键名
     * @return URL参数,如果没有匹配返回null
     */
    getParameter : function(key)
    {
        var search = document.location.search;
        var pattern = new RegExp("[?&]"+key+"\=([^&]+)", "g");
        var matcher = pattern.exec(search);
        var items = null;
        if(null != matcher){
            items = this.decode(matcher[1]);
        }
        return items;
    },
    /**
     * 获取URL参数集
     * @param key
     * @return 返回匹配key的所有值
     */
    getParameterValues : function(key)
    {
        var search = document.location.search;
        var pattern = new RegExp("[?&]"+key+"\=([^&]+)", "g");
        var matcher = null;
        var items = [];
        while(null != (matcher = pattern.exec(search))){
            items.push(this.decode(matcher[1]));
        }
        return items;
    },
    /**
     * 获取相对位置
     * @param ref 参考节点
     * @return {x,y}
     */
    getPosition : function(ref)
    {
        var _x = 0;
        var _y = 0;
        while(null != ref.offsetParent)
        {
            _x += ref.offsetLeft;
            _y += ref.offsetTop;
            ref = ref.offsetParent;
        }
        return {x:_x, y:_y};
    }
};
/**
 * 构造函数
 * ajax对象
 * @version 1.4
 */
function Ajax()
{
    this.parent = RIAClient;
    this.config = {
        method : "POST",
        asynch : true,
        contentType : "application/x-www-form-urlencoded; charset=UTF-8",
        cache : false,
        proxy : null,
        url : null,
        param : null,
        formName : null,
        handler : null,
        args : [],
        isXML : true,
        timeout : 5000,
        interval : -1,
        tryTimes : -1
    };
    this.Request = {
        UNINITIALIZED : 0,
        LOADING       : 1,
        LOADED        : 2,
        INTERACTIVE   : 3,
        COMPLETED     : 4
    };
    this.instance = null;
    this.timeoutId = null;
    this.intervalId = null;
    this.requestTimes = 0;
}
Ajax.prototype = {
    /**
     * 设置配置参数信息
     * @param config 对象
     * config.method       请求时用的方法,默认为 POST
     * config.asynch       是否为异步,默认为true
     * config.contentType  请求时的Content-Type, 默认为 application/x-www-form-urlencoded; charset=UTF-8
     * config.cache        是否缓存 默认为true
     * config.proxy        代理 默认为null
     * config.url          请求URL
     * config.param        参数
     * config.formName     表单名
     * config.handler      处理函数
     * config.args         处理函数参数
     * config.isXML        响应类型 true:xml false:text 默认为true
     * config.timeout      请求超时时间
     * config.interval     请求周期
     * config.tryTimes     请求失败时尝试次数
     */
    setConfig : function(config)
    {
        config = config || {};
        this.config.method = (config.method || this.config.method).toUpperCase();
        this.config.asynch = typeof(config.asynch) == "boolean" ? config.asynch : this.config.asynch;
        this.config.contentType = config.contentType || this.config.contentType;
        this.config.cache = typeof(config.cache) == "boolean" ? config.cache : this.config.cache;
        this.config.proxy = config.proxy || this.config.proxy;
        this.config.url = config.url || this.config.url;
        this.config.param = config.param || this.config.param;
        this.config.formName = config.formName || this.config.formName;
        this.config.handler = config.handler || this.config.handler;
        this.config.args = config.args || this.config.args;
        this.config.isXML = typeof(config.isXML) == "boolean" ? config.isXML : this.config.isXML;
        this.config.timeout = config.timeout || this.config.timeout;
        this.config.interval = config.interval || this.config.interval;
        this.config.tryTimes = config.tryTimes || this.config.tryTimes;
    },
    /**
     * 获取配置信息
     * @return config
     */
    getConfig : function()
    {
        return this.config;
    },
    /**
     * 获取XMLHttpRequest对象实例
     * @return XMLHttpRequest对象
     */
    getInstance : function()
    {
        try
        {
            this.instance = new XMLHttpRequest();
        }
        catch(e1)
        {
            try
            {
                this.instance = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(e2)
            {
                try
                {
                    this.instance = new ActiveXObject("Msxml2.XMLHTTP");
                }
                catch (e3)
                {
                    this.instance = null;
                }
            }
        }
        return this.instance;
    },
    /**
     * 解释处理句柄
     * @param handler 函数句柄
     * @param args 句柄参数
     * @return 句柄
     * @throws handler error
     */
    evalHandler : function(handler, args)
    {
        if (typeof(handler) == "function")
        {
            handler.apply(null, args);
            this.instance = null;
        }
        else if (null != handler)
        {
            this.instance = null;
            throw new Error("Get Handler Error!\n" +
                    "Please check the handler's type.\n" +
                    "The handler's type must be a function or null.");
        }
        this.instance = null;
    },
    /**
     * 获取URL查询串 如果表单名不为空，则遍历表单元素，否则取入参param
     * return URL QueryString
     */
    getQueryString : function()
    {
        var strQuery = this.config.param;
        var formName = this.config.formName;
        if(null != formName)
        {
            qsItems = (strQuery || "").split("&");
            var qsItems = [];
            var els = [];
            var form = null;
            var el = null;
            var size = 0;
            var tagName = "";
            var type = "";
            var $parent = this.parent;
            try
            {
                form = typeof(formName) == "object" ? formName : document.forms[formName];
                els = form.elements;
                size = els.length;
                for(var i = 0; i < size; i++)
                {
                    el = els[i];
                    tagName = (el.tagName||"").toUpperCase();
                    type = (el.type||"").toUpperCase();
                    if(!el.name){continue;}
                    switch(tagName)
                    {
                        case "SELECT":
                        case "TEXTAREA":
                            qsItems.push(el.name + "=" + $parent.encode(el.value));
                        break;
                        case "INPUT":
                        {
                            switch(type)
                            {
                                case "TEXT":
                                case "PASSWORD":
                                case "HIDDEN":
                                    qsItems.push(el.name + "=" + $parent.encode(el.value));
                                break;
                                case "RADIO":
                                case "CHECKBOX":
                                {
                                    if(el.checked)
                                    {
                                        qsItems.push(el.name + "=" + $parent.encode(el.value));
                                    }
                                }
                                break;
                            }
                        }
                        break;
                    }
                }
                strQuery = qsItems.join("&");
            }
            catch(e)
            {
                throw new Error("get form data error ! \n " + e.message);
            }
            finally
            {
                qsItems = null;
                els = null;
                form = null;
                el = null;
                size = 0;
                tagName = null;
                type = null;
                $parent = null;
            }
        }
        return strQuery;
    },
    /**
     * 拼合URL
     * @return 拼合后的URL
     */
    makeURL : function()
    {
        var conf = this.config;
        var url = conf.url || "";
        var proxy = conf.proxy;
        var queryString = this.getQueryString();
        var param = null;
        var $parent = this.parent;
        if("GET" == conf.method)
        {
            url = queryString ? ((url.indexOf("?") == -1 ? "?" : "&") + queryString) : url;
        }
        else
        {
            param = queryString;
        }
        if(null != proxy)
        {
            url = proxy + (proxy.indexOf("?") == -1 ? "?" : "&") + "req_url=" + $parent.encode(url);
        }
        $parent = null; conf = null; queryString = null;
        return {URL:url, DATA:param};
    },
    /**
     * 清除超时请求
     */
    clearAbort : function()
    {
        if(null != this.timeoutId)
        {
            clearTimeout(this.timeoutId);
            this.timeoutId = null;
        }
    },
    /**
     * 清除定时器
     */
    clearCycle : function()
    {
        if(null != this.intervalId)
        {
            clearInterval(this.intervalId);
            this.intervalId = null;
        }
    },
    /**
     * 中断请求
     */
    $abort : function(xmlHttp, handler, args)
    {
        var conf = this.config;
        if(conf.timeout > 0)
        {
            var _this = this;
            this.timeoutId = setTimeout(function(){
                if(xmlHttp.readyState != _this.Request.COMPLETED)
                {
                    xmlHttp.abort();
                    if(conf.interval <= 0 &&
                            conf.tryTimes > 0 &&
                                _this.requestTimes < conf.tryTimes)
                    {
                        _this.requestTimes++;
                        args.unshift({status:"TRY#"+_this.requestTimes, data:null});
                        _this.evalHandler(handler, args);
                        args.shift();
                        _this.$send();
                    }
                    else
                    {
                        args.unshift({status:"TIMEOUT", data:null});
                        _this.evalHandler(handler, args);
                        args.shift();
                    }
                }
                _this = null;
            }, conf.timeout);
        }
        conf = null;
    },
    /**
     * 周期调用
     */
    callSender : function()
    {
        if(this.config.interval > 0)
        {
            var ajax = this;
            this.$send();
            this.intervalId = setInterval(function(){
                ajax.$send();
            }, this.config.interval);
        }
        else
        {
            this.$send();
        }
    },
    /**
     * 请求完成
     */
    $completed : function(xhr, handler, args, isRX)
    {
        var conf = this.config;
        if (200 == xhr.status || 0 === xhr.status)
        {
            args.unshift({status:xhr.status, data:(isRX ? xhr.responseXML : xhr.responseText)});
            this.evalHandler(handler, args);
            args.shift();
        }
        else
        {
            if(conf.interval <= 0 &&
                    conf.tryTimes > 0 &&
                        this.requestTimes < conf.tryTimes)
            {
                this.requestTimes++;
                args.unshift({status:"TRY#"+this.requestTimes, data:null});
                this.evalHandler(handler, args);
                args.shift();
                this.$send();
            }
            else
            {
                args.unshift({status:xhr.status, data:null});
                this.evalHandler(handler, args);
                args.shift();
            }
        }
        conf = null;
        xhr = null;
    },
    /**
     * 发送请求
     * @throws 获取XMLHttpRequest失败
     * @throws 运行期发生异常
     */
    $send : function()
    {
        var conf = this.config;
        try
        {
            var xhr = this.getInstance();
            var isRX = conf.isXML;
            var handler = conf.handler;
            var args = conf.args;
            var url = this.makeURL();
            var ajax = this;
            if (null != xhr)
            {
                xhr.open(conf.method, url.URL, conf.asynch);
                if (!conf.cache)
                {
                    xhr.setRequestHeader("No-Cache","1");
                    xhr.setRequestHeader("Pragma","no-cache");
                    xhr.setRequestHeader("Cache-Control","no-cache");
                    xhr.setRequestHeader("Expire","0");
                    xhr.setRequestHeader("Last-Modified","Thu, 1 Jan 1970 00:00:00 GMT");
                    xhr.setRequestHeader("If-Modified-Since","-1");
                }
                xhr.setRequestHeader("Content-Type", conf.contentType);
                if(conf.asynch)
                {
                    xhr.onreadystatechange = function()
                    {
                        if (xhr.readyState == ajax.Request.COMPLETED)
                        {
                            ajax.$completed(xhr, handler, args, isRX);
                            ajax = null;
                        }
                    };
                }
                xhr.send(url.DATA);
                this.$abort(xhr, handler, args);
                if(!conf.asynch)
                {
                    this.$completed(xhr, handler, args, isRX);
                }
            }
            else
            {
                throw new Error("Get XMLHttpRequest Object Failure!");
            }
        }
        catch(e)
        {
            throw new Error("An Runtime Error Occurred ! \n\n" + e.message);
        }
        finally
        {
            conf = null;
        }
    },
    /**
     * 发送请求
     * @param config 对象
     * config.method       请求时用的方法,默认为 POST
     * config.asynch       是否为异步,默认为true
     * config.contentType  请求时的Content-Type, 默认为 application/x-www-form-urlencoded; charset=UTF-8
     * config.cache        是否缓存 默认为true
     * config.proxy        代理 默认为null
     * config.url          请求URL
     * config.param        参数
     * config.formName     表单名
     * config.handler      处理函数
     * config.args         处理函数参数
     * config.isXML        响应类型 true:xml false:text 默认为true
     * config.timeout      请求超时时间
     * config.interval     请求周期
     * config.tryTimes     请求失败时尝试次数
     */
    sendRequest : function(config)
    {
        this.instance = null;
        this.requestTimes = 0;
        this.clearAbort();
        this.clearCycle();
        this.setConfig(config);
        this.callSender();
    }
};

/**
 * XPath表达式
 * 构造函数
 * @version 1.1
 * @param xpathText 表示要编译的 XPath 表达式的字符串。
 * @param namespaceURLMapper 从一个名字空间前缀映射到一个全称名字空间 URL 的一个函数。如果不需要这样的映射，则为 null。
 */
function XPathExpression(xpathText, namespaceURLMapper)
{
    this.XPathText = xpathText;
    this.namespaceURLMapper = namespaceURLMapper;
    if(document.createExpression)
    {
        this.expression = document.createExpression(xpathText, function(prefix){
            return namespaceURLMapper[prefix];
        });
    }
    else
    {
        this.namespacesString = "";
        if(null != namespaceURLMapper)
        {
            for(var prefix in namespaceURLMapper)
            {
                if(this.namespacesString) this.namespacesString += ' ';
                this.namespacesString += 'xmlns:' + prefix + '="' + namespaceURLMapper[prefix] + '"';
            }
        }
    }
};
XPathExpression.prototype = {
    /**
     * 获取匹配xpath的节点
     * @param context 文档或元素对象
     * @return NodeList 如果没有找到匹配返回null
     */
    selectNodes : function(context)
    {
        var nodeList = null;
        var result = null;
        var oEvaluator = null;
        var doc = null;
        if(this.expression)
        {
            result = null;
            oEvaluator = new XPathEvaluator();
            result = oEvaluator.evaluate(this.XPathText,
                                      context,
                                      this.namespaceURLMapper,
                                      XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
                                      null);
            var length = result.snapshotLength;
            if(length > 0)
            {
                nodeList = new Array();
                for(var i = 0; i < length; i++)
                {
                    if(1 == result.snapshotItem(i).nodeType)
                        nodeList.push(result.snapshotItem(i));
                }
            }
            result = null;
            oEvaluator = null;
            context = null;
            return nodeList;
        }
        else
        {
            try
            {
                doc = context.ownerDocument;
                if(null == doc)
                {
                    doc = context;
                }
                doc.setProperty("SelectionLanguage", "XPath");
                doc.setProperty("SelectionNamespaces", this.namespacesString);
                if(doc == context)
                {
                    context = doc.documentElement;
                }
                nodeList = context.selectNodes(this.XPathText);
            }
            catch(e)
            {
                throw new Error("对不起，您的浏览器不支XPath！desc = " + e.message);
            }
            finally
            {
                doc = null;
                context = null;
                return nodeList;
            }
        }
    },
    /**
     * 获取匹配xpath的的第一个节点
     * @param context 文档或元素对象
     * @return Node 如果没有找到匹配返回null
     */
    selectSingleNode : function(context)
    {
        var node = null;
        var result = null;
        var oEvaluator = null;
        var doc = null;
        if(this.expression)
        {
            result = null;
            oEvaluator = new XPathEvaluator();
            result = oEvaluator.evaluate(this.XPathText,
                                      context,
                                      this.namespaceURLMapper,
                                      XPathResult.FIRST_ORDERED_NODE_TYPE,
                                      null);
            node = result.singleNodeValue;
            result = null;
            oEvaluator = null;
            context = null;
            return node;
        }
        else
        {
            try
            {
                doc = context.ownerDocument;
                if(null == doc)
                {
                    doc = context;
                }
                doc.setProperty("SelectionLanguage", "XPath");
                doc.setProperty("SelectionNamespaces", this.namespacesString);
                if(doc == context)
                {
                    context = doc.documentElement;
                }
                node = context.selectSingleNode(this.XPathText);
                doc = null; context = null;
            }
            catch(e)
            {
                throw new Error("对不起，您的浏览器不支XPath！desc = " + e.message);
            }
            finally
            {
                doc = null;
                context = null;
                return node;
            }
        }
    }
};
/**
 * XML接口
 * 构造函数
 * @version 1.2
 */
function JXML()
{
    this.XMLDocument = null;
};
JXML.prototype = {
    /**
     * 建立一个新的XML文档
     * @param namespace 命名空间URI
     * @param root 根节点名
     * @param doctype 文档类型
     * @return XML文档
     * @throws 参数错误
     */
    createXMLDocument : function(namespace, root, doctype)
    {
        if(3 != arguments.length)
        {
            throw new Error("建立XML文档时参数错误; length = " + arguments.length);
        }
        var rootTagName = root || "";
        var namespaceURI = namespace || "";
        var docType = doctype || null;
        var xmlDoc = null;
        if(document.implementation && document.implementation.createDocument)
        {
            xmlDoc = document.implementation.createDocument(namespaceURI, rootTagName, docType);
        }
        else
        {
            xmlDoc = new ActiveXObject("MSXML2.DOMDocument");
            if(rootTagName)
            {
                var hasPrefix = rootTagName.indexOf(":") != -1 && namespaceURI;
                var prefix = hasPrefix ? rootTagName.split(":")[0] : "";
                var tagName = hasPrefix ? rootTagName.split(":")[1] : rootTagName;
                var xmlStr = "<" + (hasPrefix ? prefix + ":" : "") + tagName +
                                (hasPrefix ? " xmlns:" + prefix + "=\"" + namespaceURI + "\"" : "") + " />";
                xmlDoc.loadXML(xmlStr);
            }
        }
        this.XMLDocument = xmlDoc;
        xmlDoc = null;
        return this.XMLDocument;
    },
    /**
     * 加载XML文档
     * @param url 文档地址
     * @return XML文档
     */
    load : function(url)
    {
        var xmlDoc = this.createXMLDocument(null, null, null);
        try
        {
            xmlDoc.async = false;
            xmlDoc.load(url);
        }
        catch(e)
        {
            var request = new XMLHttpRequest();
            request.open("GET", url, false);
            request.send(null);
            xmlDoc = request.responseXML;
            request = null;
        }
        finally
        {
            this.XMLDocument = xmlDoc;
            xmlDoc = null;
            return this.XMLDocument;
        }
    },
    /**
     * 加载XML
     * @param xmlStr xml格式字符串
     * @return XML文档
     */
    loadXML : function(xmlStr)
    {
        var xmlDoc = null;
        if("undefined" != typeof(DOMParser))
        {
            var parser = new DOMParser();
            xmlDoc = parser.parseFromString(xmlStr, "application/xml");
            parser = null;
        }
        else if(window.ActiveXObject)
        {
            xmlDoc = createXMLDocument(null, null, null);
            xmlDoc.async = false;
            xmlDoc.loadXML(xmlStr);
        }
        else /* for Safari */
        {
            var url = "data:text/xml;charset=utf-8," + encodeURIComponent(xmlStr);
            var request = new XMLHttpRequest();
            request.open("GET", url, false);
            request.send(null);
            xmlDoc = request.responseXML;
            request = null;
        }
        this.XMLDocument = xmlDoc;
        xmlDoc = null;
        return this.XMLDocument;
    },
    /**
     * 获取匹配xpath的节点
     * @param context 文档或元素对象
     * @param xpath XPATH查询串
     * @param namespaceURLMapper 从一个名字空间前缀映射到一个全称名字空间 URL 的一个函数。如果不需要这样的映射，则为 null。
     * @return NodeList 如果没有找到匹配返回null
     */
    selectNodes : function(context, xpathText, namespaceURLMapper)
    {
        var xPath = new XPathExpression(xpathText, namespaceURLMapper);
        var nodes = xPath.selectNodes(context);
        xPath = null;
        return nodes;
    },
    /**
     * 获取匹配xpath的的第一个节点
     * @param context 文档或元素对象
     * @param xpath XPATH查询串
     * @param namespaceURLMapper 从一个名字空间前缀映射到一个全称名字空间 URL 的一个函数。如果不需要这样的映射，则为 null。
     * @return Node 如果没有找到匹配返回null
     */
    selectSingleNode : function(context, xpathText, namespaceURLMapper)
    {
        var xPath = new XPathExpression(xpathText, namespaceURLMapper);
        var node = xPath.selectSingleNode(context);
        xPath = null;
        return node;
    },
    /**
     * 将XML文档或节点转成字符串
     * @param node 元素节点
     * @return xml序列化后的字符串
     */
    toString : function(node)
    {
        var fragment = node || this.XMLDocument || null;
        var xmlStr = "";
        if(null != fragment)
        {
            if("undefined" != typeof(XMLSerializer))
            {
                var serializer = new XMLSerializer();
                xmlStr = serializer.serializeToString(fragment);
                serializer = null;
            }
            else if(fragment.xml)
            {
                xmlStr = fragment.xml;
            }
        }
        return xmlStr;
    }
};

/**
 * xml tree
 * 构造函数
 * @version 1.1
 */
function XMLTree()
{
    this.parent = RIAClient;
    this.XML = new JXML();
    this.events = null;
    this.mark = null;
    this.input = null;
    this.root = null;
    this.tree = null;
    this.id = "XMLTree";
    this.constant = {
        NORMAL : 0,
        SINGLE : 1,
        MULTI  : 2,
        PREFIX : "XMLTREE_",
        PANEL  : "PANEL_",
        PARENT : "PARENT_",
        CHILD  : "CHILD_",
        MARK   : "MARK_",
        INPUT  : "INPUT_",
        ICON   : "ICON_",
        LINK   : "LINK_"
    };
    this.type = this.constant.NORMAL;
    this.panel = null;
};
XMLTree.prototype = {
    /**
     * 加载xml树
     * @param xml xml文件
     * @throws 参数错误
     */
    loadTree : function(xml)
    {
        if(!xml)
        {
            throw new Error("必须指定一个xml文件");
        }
        var xmlDoc = null;
        var tree = this;
        this.XML.load(xml);
        this.loaded();
    },
    /**
     * 加载完成后的处理函数
     */
    loaded : function()
    {
        this.tree = this.XML.XMLDocument ? this.XML.XMLDocument.documentElement : null;
        if(null != this.tree)
        {
            this.id = this.tree.getAttribute("id") || "XMLTree";
            this.type = parseInt(this.tree.getAttribute("type") || this.constant.NORMAL, 10);
            this.constant.PREFIX = "XMLTREE_" + this.id + "_";
            this.events = this.getEvents();
            this.mark = this.getMark();
            this.input = this.getInputEvents();
            this.root = this.getRoot();
            this.createTreePanel(this.tree.getAttribute("position"));
            this.showTree(this.tree.getAttribute("position")||null);
        }
    },
    /**
     * 获取events节点数据
     * @return events
     */
    getEvents : function()
    {
        var eventsNode = this.tree.getElementsByTagName("events")[0];
        var children = eventsNode.childNodes;
        var size = children.length;
        var _events = size > 0 ? new Object() : null;
        for(var i = 0; i < size; i++)
        {
            if(1 == children[i].nodeType)
            {
                _events.put((children[i].tagName).toLowerCase(), children[i].getAttribute("handler")||null);
            }
        }
        return _events;
    },
    /**
     * 获取mark节点数据
     * @return mark
     */
    getMark : function()
    {
        var markNode = this.tree.getElementsByTagName("mark")[0];
        var _minus = markNode.getAttribute("minus");
        var _plus = markNode.getAttribute("plus");
        var _mark = {minus:_minus, plus:_plus};
        return _mark;
    },
    /**
     * 获取input节点数据
     * @return input events
     */
    getInputEvents : function()
    {
        var inputNode = this.tree.getElementsByTagName("input")[0];
        var children = inputNode.childNodes;
        var size = children.length;
        var _events = size > 0 ? new Object() : null;
        for(var i = 0; i < size; i++)
        {
            if(1 == children[i].nodeType)
            {
                _events.put((children[i].tagName).toLowerCase(), children[i].getAttribute("handler")||null);
            }
        }
        return _events;
    },
    /**
     * 获取root节点数据
     * @return root
     */
    getRoot : function()
    {
        var rootNode = this.tree.getElementsByTagName("root")[0];
        return rootNode;
    },
    /**
     * 获取节点的属性
     * @param node 节点
     * @return attributes;
     */
    getNodeAttribute : function(node)
    {
        var _id = node ? node.getAttribute("id") || null : null;
        var _show = node ? node.getAttribute("show") == "true" : false;
        var _icon = node ? node.getAttribute("icon") || null : null;
        var _edit = node ? node.getAttribute("edit") == "true" : false;
        var _selected = node ? node.getAttribute("selected") == "true" : false;
        var _link = node ? node.getAttribute("link") || null : null;
        var _target = node ? node.getAttribute("target") || "_blank" : "_blank";
        var _value = node ? node.getAttribute("value") || null : null;
        var _label = node ? node.getAttribute("label") || _value : _value;
        var attrs = {id:_id, show:_show, icon:_icon, edit:_edit, selected:_selected, link:_link, target:_target, value:_value, label:_label};
        return attrs;
    },
    /**
     * 获取当前父节点下的子节点
     * @param parentNode 父节点
     * @return nodes
     */
    getChildNodes : function(parentNode)
    {
        var nodes = [];
        if(parentNode)
        {
            nodes = parentNode.childNodes;
        }
        return nodes;
    },
    /**
     * 获取当前父节点下的所有子节点
     * @param parentNode 父节点
     * @param tagName 标签名
     * @return nodes
     */
    getAllChildNodes : function(parentNode, tagName)
    {
        return parentNode.getElementsByTagName(tagName);
    },
    /**
     * 获取节点
     * @param xpath xpath表达式
     * @return NodeList
     */
    getNodes : function(xpath)
    {
        return this.XML.selectNodes(this.XML.XMLDocument, xpath, null);
    },
    /**
     * 获取节点
     * @param xpath xpath表达式
     * @return Node
     */
    getNode : function(xpath)
    {
        return this.XML.selectSingleNode(this.XML.XMLDocument, xpath, null);
    },
    /**
     * 是否有子节点
     * @param parentNode 父节点
     * @return true/false
     */
    hasChildNodes : function(parentNode)
    {
        var nodes = this.getChildNodes(parentNode);
        return nodes.length > 0;
    },
    /**
     * 将节点转化成json对象
     * @param node 节点
     * @return json对象
     */
    node2json : function(node)
    {
        return this.getNodeAttribute(node);
    },
    /**
     * 将节点转化成String
     * @param node 节点
     * @return string
     */
    node2string : function(node)
    {
        var json = this.node2json(node);
        var items = [];
        for(var i in json)
        {
            items.push(i + " = " + json[i]);
        }
        return items.join("; ");
    },
    /**
     * 建立面板
     */
    createTreePanel : function()
    {
        var panel = this.parent.$C("div");
        panel.setAttribute("id", this.constant.PREFIX + this.constant.PANEL);
        this.panel = panel;
        this.createRootNode();
    },
    /**
     * 建立根节点
     */
    createRootNode : function()
    {
        if(null != this.root)
        {
            var attrs = this.node2json(this.root);
            var ul = this.parent.$C("ul");
            var node = this.createHTMLNode(this.root, true);
            ul.setAttribute("id", this.constant.PREFIX + this.constant.PARENT + "ROOT");
            this.parent.$A(node, ul);
            this.parent.$A(this.createHTMLNodes(this.root, false), node);
            this.parent.$A(ul, this.panel);
        }
    },
    /**
     * 建HTML节点集
     * @param root 父节点
     * @param isRoot 是否为根节点
     * @return html节点
     */
    createHTMLNodes : function(root, isRoot)
    {
        var attrs = this.node2json(root);
        var ul = this.parent.$C("ul");
        var node = this.createHTMLNode(root);
        var nodes = this.getChildNodes(root);
        var size = nodes.length;
        ul.setAttribute("id", this.constant.PREFIX + this.constant.PARENT + attrs.id);
        ul.style.cssText = "margin-left:8px;"
        for(var i = 0; i < size; i++)
        {
            if(1 == nodes[i].nodeType)
            {
                this.parent.$A(this.createHTMLNode(nodes[i], isRoot), ul);
            }
        }
        return ul;
    },
    /**
     * 建立单个HTML节点
     * @param node 当前节点
     * @param isRoot 是否为根节点
     * @return node
     */
    createHTMLNode : function(node, isRoot)
    {
        var hasChild = this.hasChildNodes(node);
        var attrs = this.node2json(node);
        var li = this.parent.$C("li");
        var mark = this.parent.$C("img");
        var link = this.parent.$C("a");
        var input = null;
        var icon = null;
        var tree = this;
        li.setAttribute("id", this.constant.PREFIX + this.constant.CHILD + attrs.id);
        mark.setAttribute("id", this.constant.PREFIX + this.constant.MARK + attrs.id);
        mark.setAttribute("src", hasChild ? (isRoot ? this.mark.minus : this.mark.plus) : this.mark.minus);
        mark.setAttribute("width", 9);
        mark.setAttribute("height", 9);
        mark.setAttribute("border", 0);
        mark.setAttribute("align", "absmiddle");
        mark.style.cssText = "margin-right:3px;";
        mark.attachEvent("onclick", function()
        {
            if(hasChild)
            {
                tree.switchMark(mark, node);
                if(tree.constant.MULTI == tree.type)
                {
                    tree.resetState(tree.constant.PREFIX + tree.constant.INPUT + attrs.id);
                }
            }
        });
        link.setAttribute("id", this.constant.PREFIX + this.constant.LINK + attrs.id);
        if(null != attrs.link)
        {
            link.setAttribute("href", attrs.link);
            link.setAttribute("target", attrs.target);
        }
        else
        {
            link.style.cursor = "default";
        }
        link.attachEvent("onclick", function()
        {
            if(hasChild)
            {
                tree.switchMark(mark, node);
                if(tree.constant.MULTI == tree.type)
                {
                    tree.resetState(tree.constant.PREFIX + tree.constant.INPUT + attrs.id);
                }
            }
        });
        if(this.constant.NORMAL != this.type)
        {
            input = this.parent.$C("input");
            input.setAttribute("id", this.constant.PREFIX + this.constant.INPUT + attrs.id);
            if(this.constant.SINGLE == this.type)
            {
                input.setAttribute("type", "radio");
            }
            if(this.constant.MULTI == this.type)
            {
                input.setAttribute("type", "checkbox");
                input.attachEvent("onclick", function(){tree.changeState(input);});
            }
            input.style.cssText = "margin-right:3px;";
        }
        if(attrs.icon)
        {
            icon = this.parent.$C("img");
            icon.setAttribute("id", this.constant.PREFIX + this.constant.ICON + attrs.id);
            icon.setAttribute("src", attrs.icon);
            icon.setAttribute("width", 16);
            icon.setAttribute("height", 16);
            icon.setAttribute("border", 0);
            icon.setAttribute("align", "absmiddle");
            icon.style.cssText = "margin-right:3px;";
        }
        this.parent.$A(this.parent.$X(attrs.label), link);
        this.parent.$A(mark, li);
        if(this.constant.NORMAL != this.type)
        {
            this.parent.$A(input, li);
            input.value = attrs.value;
            input.checked = attrs.selected;
        }
        if(attrs.icon)
        {
            this.parent.$A(icon, li);
        }
        this.parent.$A(link, li);
        return li;
    },
    /**
     * 显示树
     * @param target 目标位置
     */
    showTree : function(target)
    {
        if("string" == typeof(target))
        {
            this.parent.$A(this.panel, this.parent.$E(target));
        }
        else
        {
            this.parent.$A(this.panel, target);
        }
    },
    /**
     * 切换节点状态
     * @param mark 标识
     * @param node 节点
     */
    switchMark : function(mark, node)
    {
        var src = mark.src;

        if(src.indexOf(this.mark.minus) == -1)
        {
            this.expand(mark, node);
        }
        else
        {
            this.collapse(mark, node);
        }
    },
    /**
     * 展开
     * @param mark 标识
     * @param node 节点
     */
    expand : function(mark, node)
    {
        var parentNode = mark.parentNode;
        var ul = parentNode.lastChild;
        var id = parentNode.getAttribute("id");
        id = id.substring(id.lastIndexOf("_") + 1);
        mark.src = this.mark.minus;
        if((ul.tagName).toLowerCase() == "ul")
        {
            ul.style.display = "block";
        }
        else
        {
            this.parent.$A(this.createHTMLNodes(node, false), parentNode);
        }
    },
    /**
     * 收缩
     * @param mark 标识
     * @param node 节点
     */
    collapse : function(mark, node)
    {
        var parentNode = mark.parentNode;
        var ul = parentNode.lastChild;
        var id = parentNode.getAttribute("id");
        id = id.substring(id.lastIndexOf("_") + 1);
        mark.src = this.mark.plus;
        if((ul.tagName).toLowerCase() == "ul")
        {
            ul.style.display = "none";
        }
    },
    /**
     * 改变多选框状态
     * @param input 多选框对象
     */
    changeState : function(input)
    {
        if(input.checked)
        {
            this.checked(input);
        }
        else
        {
            this.unchecked(input);
        }
    },
    /**
     * 重新改变多选框状态
     * @param id 多选框ID
     */
    resetState : function(id)
    {
        var input = this.parent.$E(id);
        this.changeState(input);
    },
    /**
     * 选择
     * @param input 多选框对象
     */
    checked : function(input)
    {
        var idStr = input.id;
        var id = idStr.substring(idStr.lastIndexOf("_") + 1);
        var parentNode = this.parent.$E(this.constant.PREFIX + this.constant.PARENT + id);
        var subList = [];
        var size = 0;
        if(parentNode)
        {
            subList = parentNode.getElementsByTagName("input");
            size = subList.length;
            for(var i = 0; i < size; i++)
            {
                subList[i].checked = true;
            }
        }
        this.checkedParent(input);
    },
    /**
     * 取消选择
     * @param input 多选框对象
     */
    unchecked : function(input)
    {
        var idStr = input.id;
        var id = idStr.substring(idStr.lastIndexOf("_") + 1);
        var parentNode = this.parent.$E(this.constant.PREFIX + this.constant.PARENT + id);
        var subList = [];
        var size = 0;
        if(parentNode)
        {
            subList = parentNode.getElementsByTagName("input");
            size = subList.length;
            for(var i = 0; i < size; i++)
            {
                subList[i].checked = false;
            }
        }
        this.uncheckedParent(input);
    },
    /**
     * 选择父节点
     * @param input 多选框对象
     */
    checkedParent : function(input)
    {
        var parentNode = input.parentNode.parentNode;
        var idStr = parentNode.id;
        var id = idStr.substring(idStr.lastIndexOf("_") + 1);
        var parentInput = this.parent.$E(this.constant.PREFIX + this.constant.INPUT + id);
        var subList = [];
        var size = 0;
        var flag = false;
        if(parentNode)
        {
            subList = parentNode.getElementsByTagName("input");
            size = subList.length;
            for(var i = 0; i < size; i++)
            {
                if(subList[i].checked)
                {
                    flag = true;
                    break;
                }
            }
        }
        if(flag && null != parentInput)
        {
            parentInput.checked = true;
            this.checkedParent(parentInput)
        }
    },
    /**
     * 取消选择父节点
     * @param input 多选框对象
     */
    uncheckedParent : function(input)
    {
        var parentNode = input.parentNode.parentNode;
        var idStr = parentNode.id;
        var id = idStr.substring(idStr.lastIndexOf("_") + 1);
        var parentInput = this.parent.$E(this.constant.PREFIX + this.constant.INPUT + id);
        var subList = [];
        var size = 0;
        var flag = true;
        if(parentNode)
        {
            subList = parentNode.getElementsByTagName("input");
            size = subList.length;
            for(var i = 0; i < size; i++)
            {
                if(subList[i].checked)
                {
                    flag = false;
                    break;
                }
            }
        }
        if(flag && null != parentInput)
        {
            parentInput.checked = false;
            this.uncheckedParent(parentInput)
        }
    }
};

/**
 * 构造函数
 * 验证器
 * @version 1.1
 */
function Validator()
{
    this.items = new Array();
    this.Types = {
        INT         : "int",
        BOOLEAN     : "boolean",
        CHAR        : "char",
        EMAIL       : "email",
        EN          : "en",
        ENUM        : "enum",
        FLOAT       : "float",
        FILTER      : "filter",
        LETTER      : "letter",
        MOBILE      : "mobile",
        NUMBER      : "number",
        TEL         : "tel",
        URL         : "url",
        NULL        : null
    };
};
Validator.prototype = {
    /**
     * 添加验证项
     * item 验证项
     * item.id  验证项ID
     * item.text  验证项标签
     * item.dataType 数据类型
     * item.isNull  是否为空
     * item.minValue 最小值
     * item.maxValue 最大值
     */
    addItem : function(item)
    {
        this.items.push({
            id:item.id,
            text:item.text,
            dataType:item.dataType,
            isNull:item.isNull,
            minValue:item.minValue,
            maxValue:item.maxValue});
    },

    /**
     * 移除验证项
     * @param itemId 验证项ID
     */
    removeItem : function(itemId)
    {
        for (var i = this.items.length - 1; i >=0; i--)
        {
            if(itemId == this.items[i].id)
            {
                this.items.splice(i,1);
            }
        }
    },

    /**
     * 移除所有验证项
     */
    removeAllItem : function()
    {
        this.items = null;
        this.items = new Array();
    },

    /**
     * 验证是否为整型
     * @param v 检测值
     * @return true/false
     */
    isInt : function(v)
    {
        var pattern = /^\-?\d+$/mi;
        return pattern.test(v);
    },

    /**
     * 验证是否为浮点型
     * @param v 检测值
     * @return true/false
     */
    isFloat : function(v)
    {
        var pattern = /^\-?\d+\.\d+$/mi;
        return pattern.test(v);
    },

    /**
     * 验证是否为数字
     * @param v 检测值
     * @return true/false
     */
    isNumber : function(v)
    {
        var pattern = /^\d+$/mi;
        return pattern.test(v);
    },

    /**
     * 验证是否为字符
     * @param v 检测值
     * @return true/false
     */
    isChar : function(v)
    {
        var pattern = /^[\u0000-\u00FF]{1}$/mi;
        return pattern.test(v);
    },

    /**
     * 验证是否为字母
     * @param v 检测值
     * @return true/false
     */
    isLetter : function(v)
    {
        var pattern = /^[a-z]{1}$/mi;
        return pattern.test(v);
    },

    /**
     * 验证是否为英文
     * @param v 检测值
     * @return true/false
     */
    isEn : function(v)
    {
        var pattern = /^[a-z]+$/mi;
        return pattern.test(v);
    },

    /**
     * 验证是否为英文加数字
     * @param v 检测值
     * @return true/false
     */
    isENum : function(v)
    {
        var pattern = /^[0-9a-z]+$/mi;
        return pattern.test(v);
    },

    /**
     * 验证是否为布尔
     * @param v 检测值
     * @return true/false
     */
    isBoolean : function(v)
    {
        var pattern = /^(true|false)$/mi;
        return pattern.test(v);
    },

    /**
     * 验证是否为有效email
     * @param v 检测值
     * @return true/false
     */
    isEmail : function(v)
    {
        var pattern = /^[^\s\@]+\@[^\s\@]+$/mi;
        return pattern.test(v);
    },

    /**
     * 验证是否为有效url
     * @param v 检测值
     * @return true/false
     */
    isURL : function(v)
    {
        var pattern = /^(http|https|ftp|file)\:\/\/[\w\W]+$/mi;
        return pattern.test(v);
    },

    /**
     * 验证是否为有效电话号码
     * @param v 检测值
     * @return true/false
     */
    isTel : function(v)
    {
        var pattern = /^(\d{3,4}-?)?(\d{7,8})(-?\d+)*$/mi;
        return pattern.test(v);
    },

    /**
     * 验证是否为有效有机号
     * @param v 检测值
     * @return true/false
     */
    isMobile : function(v)
    {
        var pattern = /^(13|15|18)\d{9}$/mi;
        return pattern.test(v);
    },

    /**
     * 验证是否为函有非法字符
     * @param v 检测值
     * @return true/false
     */
    isFilter : function(v)
    {
        var pattern = /^[^\\\/\?\:\"\<\>\|]+$/mi;
        return pattern.test(v);
    },

    /**
     * 验证值的长度
     * @param v 检测值
     * @return 验证值的长度
     */
    length : function(v)
    {
        return v.size();
    },

    /**
     * 去空
     * @param v 检测值
     * @return 去空后的检测值
     */
    trim : function(v)
    {
        return v.trim();
    },

    /**
     * 是否为空
     * @param v 检测值
     * @return true/false
     */
    isEmpty : function(v)
    {
        return (this.length(this.trim(v)) <= 0 ||
                    null == v ||
                    "null" == v.toLowerCase() ||
                    "undefined" == v.toLowerCase() ||
                    "n/a" == v.toLowerCase() ||
                    typeof(v) == "undefined");
    },

    /**
     * 校验数据类型
     * @param dt 数据类型
     * @param v 需要校验的值
     * @return true/false
     */
    isMatch : function(dt, v)
    {
        switch(dt)
        {
            case this.Types.INT:
                return this.isInt(v);
            case this.Types.BOOLEAN:
                return this.isBoolean(v);
            case this.Types.CHAR:
                return this.isChar(v);
            case this.Types.EMAIL:
                return this.isEmail(v);
            case this.Types.EN:
                return this.isEn(v);
            case this.Types.ENUM:
                return this.isENum(v);
            case this.Types.FLOAT:
                return this.isFloat(v);
            case this.Types.FILTER:
                return this.isFilter(v);
            case this.Types.LETTER:
                return this.isLetter(v);
            case this.Types.MOBILE:
                return this.isMobile(v);
            case this.Types.NUMBER:
                return this.isNumber(v);
            case this.Types.TEL:
                return this.isTel(v);
            case this.Types.URL:
                return this.isURL(v);
            case this.Types.NULL:
                return true;
            default:
                return false;
        }
    },

    /**
     * 根据数据类型获取提示信息
     * @param dt 数据类型
     * @return 提示字符串
     */
    dataTypeTip : function(dt)
    {
        switch(dt)
        {
            case this.Types.INT:
                return "的值只能是整型的数字\n如：-1,24,0";
            case this.Types.BOOLEAN:
                return "的值只能是true或者false";
            case this.Types.CHAR:
                return "的值只能单个的字符\n如：a,e,U,O";
            case this.Types.EMAIL:
                return "的格式不正确\n格式为：username@dommain.com";
            case this.Types.EN:
                return "的值只能是英文字符";
            case this.Types.ENUM:
                return "的值只能是英文字符加数字的组合";
            case this.Types.FLOAT:
                return "的值只能是小数\n如：23.9,0.0,-1.8";
            case this.Types.FILTER:
                return "的值不能含有\\\/\?\:\"\<\>\|等非法字符";
            case this.Types.LETTER:
                return "的值只能是英文字母";
            case this.Types.MOBILE:
                return "的格式不正确\n格式为：[13|15|18]XXXXXXXX";
            case this.Types.NUMBER:
                return "的值只能是数字";
            case this.Types.TEL:
                return "的格式不正确\n格式为：[0755][-]88888888[-][1234]";
            case this.Types.URL:
                return "的格式不正确\n格式为：[http|https|ftp|file]://domain.com";
            default:
                return null;
        }
    },

    /**
     * 校验边界值
     * @param dt 数据类型
     * @param v 需要校验的值
     * @param min 最小值
     * @param max 最大值
     * @return 集合 是否小于最小值和大于最值
     */
    limit : function(dt, v, min, max)
    {
        var _isMin = false;
        var _isMax = false;
        switch(dt)
        {
            case this.Types.INT:
            {
                if (null != min)
                {
                    if (parseInt(v, 10) < min)
                    {
                        _isMin = true;
                    }
                }
                if (null != max)
                {
                    if (parseInt(v, 10) > max)
                    {
                        _isMax = true;
                    }
                }
                return {isMin:_isMin, isMax:_isMax, type:"的值"};
            }
            case this.Types.FLOAT:
            {
                if (null != min)
                {
                    if (parseFloat(v, 10) < min)
                    {
                        _isMin = true;
                    }
                }
                if (null != max)
                {
                    if (parseFloat(v, 10) > max)
                    {
                        _isMax = true;
                    }
                }
                return {isMin:_isMin, isMax:_isMax, type:"的值"};
            }
            case this.Types.NUMBER:
            case this.Types.EN:
            case this.Types.ENUM:
            case this.Types.EMAIL:
            case this.Types.FILTER:
            case this.Types.LETTER:
            case this.Types.URL:
            {
                if (null != min)
                {
                    if (this.length(v.toString()) < min)
                    {
                        _isMin = true;
                    }
                }
                if (null != max)
                {
                    if (this.length(v.toString()) > max && max > -1)
                    {
                        _isMax = true;
                    }
                }
                return {isMin:_isMin, isMax:_isMax, type:"的长度"};
            }
            default:
                return {isMin:false, isMax:false, type:""};
        }
    },

    /**
     * 校验
     */
    validate : function()
    {
        var items = this.items;
        var item = null;
        var target = null;
        var match = null;
        var lv = null;
        for (var i = 0; i < items.length; i++)
        {
            item = items[i];
            target = document.getElementById(item.id);
            if (null != target)
            {
                match = this.isMatch(item.dataType, target.value);
                lv = this.limit(item.dataType, target.value, item.minValue, item.maxValue);
                if (item.isNull)
                {
                    if (!this.isEmpty(target.value))
                    {
                        if (!match)
                        {
                            alert(item.text + this.dataTypeTip(item.dataType) + "\n value=" + target.value);
                            target.focus();
                            return false;
                        }
                        if (lv.isMin)
                        {
                            alert(item.text + lv.type + "小于" + item.minValue);
                            target.focus();
                            return false;
                        }
                        if (lv.isMax)
                        {
                            alert(item.text + lv.type + "大于" + item.maxValue);
                            target.focus();
                            return false;
                        }
                    }
                }
                else
                {
                    if (this.isEmpty(target.value))
                    {
                        alert(item.text + "的值不能为空");
                        target.focus();
                        return false;
                    }
                    else
                    {
                        if (!match)
                        {
                            alert(item.text + this.dataTypeTip(item.dataType) + "\n value=" + target.value);
                            target.focus();
                            return false;
                        }
                        if (lv.isMin)
                        {
                            alert(item.text + lv.type + "小于" + item.minValue);
                            target.focus();
                            return false;
                        }
                        if (lv.isMax)
                        {
                            alert(item.text + lv.type + "大于" + item.maxValue);
                            target.focus();
                            return false;
                        }
                    }
                }
            }
            else
            {
                alert("element [" + item.id + "(" + item.text + ")] don't exist !");
                return false;
            }
        }
        return true;
    }
};

/**
 * 构造函数
 * 加载器
 * @version 1.1
 */
function Loader()
{
    this.parent = RIAClient;
};

Loader.prototype = {
    /**
     * 动态加载javascript文件
     * @param url script文件
     * @param handler 处理函数
     * @param args 处理函数参数
     * @param charset 字符编码 默认为 utf-8
     * @param defer 是否设置defer 默认为 false
     * @param isDestory 是否加载完后就销毁 默认为 true
     */
    loadScript : function(url, handler, args, charset, defer, isDestory)
    {
        var head = this.parent.$T("head")[0];
        var script = this.parent.$C("script");
        var id = "dynamic_script_" + this.parent.getTimeStamp();
        var eventType = (undefined !== script.onreadystatechange && undefined !== script.readyState) ? "onreadystatechange" : "onload";
        var parent = this.parent;
        var _isDestory = typeof(isDestory) == "boolean" ? isDestory : true;
        script.language="javascript";
        script.type="text/javascript";
        script.src = url;
        script.id = id;
        script.charset = charset || "utf-8";
        script.defer = typeof(defer) == "boolean" ? defer : false;
        script.attachEvent(eventType, function(){
            var state = script.readyState || "loaded";
            if("loaded" == state || "complete" == state)
            {
                if(typeof(handler) == "string")
                {
                    setTimeout(function(){try{var hdl = eval(handler);hdl.apply(null, args);}catch(e){}}, 50);
                }
                else if(typeof(handler) == "function")
                {
                    setTimeout(function(){try{handler.apply(null, args);}catch(e){}}, 50);
                }
                if(_isDestory)
                {
                    parent.$D(script, head);
                }
                head = null;
                script = null;
            }
        });
        parent.$A(script, head);
    },

    /**
     * 动态加载javascript文件
     * @param url script文件
     * @param handler 处理函数
     * @param args 处理函数参数
     * @param charset 字符编码 默认为 utf-8
     * @param defer 是否设置defer 默认为 false
     * @param isDestory 是否加载完后就销毁 默认为 true
     * @param interval 超时时间
     */
    loadScriptByTimeout : function(url, handler, args, charset, defer, isDestory, interval)
    {
        var head = this.parent.$T[0];
        var script = this.parent.$C("script");
        var intvId = null;
        var isLoaded = false;
        var id = "dynamic_script_" + this.parent.getTimeStamp();
        var eventType = (undefined !== script.onreadystatechange && undefined !== script.readyState) ? "onreadystatechange" : "onload";
        var parent = this.parent;
        var _isDestory = typeof(isDestory) == "boolean" ? isDestory : true;
        script.language="javascript";
        script.type="text/javascript";
        script.src = url;
        script.id = id;
        script.charset = charset || "utf-8";
        script.defer = typeof(defer) == "boolean" ? defer : false;
        script.attachEvent(eventType, function(){
            var state = script.readyState || "loaded";
            if("loaded" == state || "complete" == state){
                if(null!=intvId)
                {
                    clearTimeout(intvId);
                    intvId = null;
                }
                if(!isLoaded)
                {
                    isLoaded = true;
                    args.unshift(false);
                    if(typeof(handler) == "string")
                    {
                        setTimeout(function(){try{var hdl = eval(handler);hdl.apply(null, args);}catch(e){}}, 50);
                    }
                    else if(typeof(handler) == "function")
                    {
                        setTimeout(function(){try{handler.apply(null, args);}catch(e){}}, 50);
                    }
                }
                if(_isDestory)
                {
                    parent.$D(script, head);
                }
                head = null;
                script = null;
            }
        });
        parent.$A(script, head);
        intvId = setTimeout(function(){
            clearTimeout(intvId);
            intvId = null;
            if(!isLoaded)
            {
                isLoaded = true;
                args.unshift(true);
                if(typeof(handler) == "string")
                {
                    setTimeout(function(){try{var hdl = eval(handler);hdl.apply(null, args);}catch(e){}}, 50);
                }
                else if(typeof(handler) == "function")
                {
                    setTimeout(function(){try{handler.apply(null, args);}catch(e){}}, 50);
                }
            }
        }, interval);
    },

    /**
     * 通过iframe加载数据
     * @param url 数据文件
     * @param handler 处理函数
     * @param args 处理函数参数
     * @param responseObj 响应数据
     * @param isDestory 是否加载完后就销毁
     * @param _parent 父级对象
     */
    loadFrame : function(url, handler, args, responseObj, isDestory, _parent)
    {
        var ifr = this.parent.$C("iframe");
        var id = "dynamic_iframe_" + this.parent.getTimeStamp();
        var parent = this.parent;
        ifr.width = 0;
        ifr.height = 0;
        ifr.src = url;
        ifr.id=id;
        ifr.name=id;
        ifr.attachEvent("onload", function(){
            try
            {
                var json = eval("ifr.contentWindow."+responseObj);
                args.unshift(json);
            }
            catch(e)
            {
                args.unshift(null);
            }
            finally
            {
                if(typeof(handler) == "string")
                {
                    setTimeout(function(){try{var hdl = eval(handler);hdl.apply(null, args);}catch(e){}}, 50);
                }
                else if(typeof(handler) == "function")
                {
                    setTimeout(function(){try{handler.apply(null, args);}catch(e){}}, 50);
                }
                if(isDestory)
                {
                    parent.$D(ifr, _parent||null);
                }
                ifr = null;
            }
        });
        parent.$A(ifr, _parent||null);
    },

    /**
     * 通过iframe加载数据
     * @param url 数据文件
     * @param handler 处理函数
     * @param args 处理函数参数
     * @param responseObj 响应数据
     * @param isDestory 是否加载完后就销毁
     * @param _parent 父级对象
     * @param interval 超时时间
     */
    loadFrameByTimeout : function(url, handler, args, responseObj, isDestory, _parent, interval)
    {
        var ifr = this.parent.$C("iframe");
        var id = "dynamic_iframe_" + this.parent.getTimeStamp();
        var isLoaded = false;
        var intvId = null;
        var parent = this.parent;
        ifr.width = 0;
        ifr.height = 0;
        ifr.src = url;
        ifr.id=id;
        ifr.name=id;
        ifr.attachEvent("onload", function(){
            if(null!=intvId)
            {
                clearTimeout(intvId);
                intvId = null;
            }
            if(!isLoaded)
            {
                isLoaded = true;
                args.unshift(false);
                try
                {
                    var json = eval("ifr.contentWindow."+responseObj);
                    args.unshift(json);
                }
                catch(e)
                {
                    args.unshift(null);
                }
                finally
                {
                    if(typeof(handler) == "string")
                    {
                        setTimeout(function(){try{var hdl = eval(handler);hdl.apply(null, args);}catch(e){}}, 50);
                    }
                    else if(typeof(handler) == "function")
                    {
                        setTimeout(function(){try{handler.apply(null, args);}catch(e){}}, 50);
                    }
                    if(isDestory)
                    {
                        parent.$D(ifr, _parent||null);
                    }
                    ifr = null;
                }
            }
            else
            {
                if(isDestory)
                {
                    $R(ifr, _parent||null);
                }
                ifr = null;
            }
        });
        parent.$A(ifr, _parent||null);
        intvId = setTimeout(function(){
            clearTimeout(intvId);
            intvId = null;
            if(!isLoaded)
            {
                isLoaded = true;
                args.unshift(true);
                args.unshift(null);
                if(typeof(handler) == "string")
                {
                    setTimeout(function(){try{var hdl = eval(handler);hdl.apply(null, args);}catch(e){}}, 50);
                }
                else if(typeof(handler) == "function")
                {
                    setTimeout(function(){try{handler.apply(null, args);}catch(e){}}, 50);
                }
            }
        }, interval);
    }
};

/**
 * 构造函数
 * 幻灯片
 * @version 1.1
 * @param id 标识
 * @param element 元素大小
 * @param bigImage 大图大小
 * @param smallImage 小图大小
 * @param type 类型
 * @param interval 定时周期
 * <div>
 *   <div>
 *     <a><img /><!-- big picture --></a>
 *   </div>
 *   <ul>
 *     <li>
 *       <a><img /><!-- small picture --></a>
 *       <dl>
 *         <dt><a><!-- heading --></a></dt>
 *         <dd><a><!-- subheading --></a></dd>
 *       </dl>
 *     </li>
 *   </ul>
 * </div>
 */
function Slide(id, element, bigImage, smallImage, type, interval)
{
    this.parent = RIAClient;
    this.constant = {
        VERTICAL      : 0,
        HORIZONTAL    : 1,
        PREFIX        : "SLIDE_" + id + "_",
        PANEL         : "PANEL_",
        IMAGE_PANEL   : "IMAGE_",
        HEADING_PANEL : "HEADING_",
        ELEMENT       : "ELEMENT_",
        SPAN          : "SPAN_",
        CODE          : "CODE_",
        BIG_HREF      : "BIG_HREF_",
        BIG_IMG       : "BIG_IMG_",
        SMALL_LI      : "SMALL_LI_",
        SMALL_HREF    : "SMALL_HREF_",
        SMALL_IMG     : "SMALL_IMG_",
        SMALL_DL      : "SMALL_DL_",
        SMALL_DT      : "SMALL_DT_",
        SMALL_DD      : "SMALL_DD_",
        SMALL_DT_A    : "SMALL_DT_A_",
        SMALL_DD_A    : "SMALL_DD_A_",
        INDEX         : "INDEX_"
    };
    this.id = id;
    this.width = element.width;
    this.height = element.height;
    this.bigImage = bigImage;
    this.smallImage = smallImage;
    this.type = type || this.constant.VERTICAL;
    this.interval = interval || 4000;
    this.count = 0;
    this.maxWidth = "auto";
    this.maxHeight = "auto";
    this.container = null;
    this.indexMap = new Object();
    this.timer = null;
    this.effectTimer = null;
    this.current = 0;
    this.offsetMargin = 8;
    this.hasAttachMouseover = false;
    this.hasAttachMouseout = false;
};
Slide.prototype = {
    /**
     * 创建面板
     * @param size 元素个数
     * @param className 样式
     */
    createPanel : function(size, className)
    {
        if(typeof(size) != "number")
        {
            throw new Error("参数错误，size为空或不为数字");
        }
        var slide = this;
        this.count = size;
        this.maxWidth = this.constant.VERTICAL == this.type ? this.bigImage.width + "px" : (this.width * this.count) + "px";
        this.maxHeight = this.constant.VERTICAL == this.type ? (this.height * this.count) + "px" : this.bigImage.height + "px";
        var panel = this.parent.$C("div");
        var image = this.parent.$C("div");
        var image_heading = this.parent.$C("span");
        var image_subheading = this.parent.$C("code");
        var heading = this.parent.$C("ul");
        var css = "display:block; width:" + this.width + "px; position:absolute; background-color:black; text-align:right; left:0px; filter:Alpha(Opacity=75); -moz-opacity:0.75; opacity:0.75;";
        var offsetHeight = this.height - this.bigImage.height;
        panel.className = className || (this.constant.VERTICAL == this.type ? "VSlide" : "HSlide");
        panel.setAttribute("id", this.constant.PREFIX + this.constant.PANEL + this.id);
        panel.style.cssText = "width:" + this.width + "px;height:" + this.height + "px;overflow:hidden;position:relative;";
        image.setAttribute("id", this.constant.PREFIX + this.constant.IMAGE_PANEL + this.id);
        image.style.cssText = "width:" + this.maxWidth + ";height:" + this.maxHeight + "; float:left; margin-right:" + this.offsetMargin + "px;";
        heading.setAttribute("id", this.constant.PREFIX + this.constant.HEADING_PANEL + this.id);
        if(this.constant.VERTICAL == this.type)
        {
            heading.style.cssText = "width:" + (this.width - this.bigImage.width - this.offsetMargin) + "px; height:" + this.height + "px;float:left;";
        }
        else
        {
            heading.style.cssText = "width:" + this.width + "px; height:26px;float:left;";
        }
        image_heading.setAttribute("id", this.constant.PREFIX + this.constant.SPAN + this.id);
        image_heading.style.cssText = css + " bottom:" + (28 + offsetHeight) + "px; line-height:36px; height:36px; font-size:26px; color:#FF6600; font-family:SimHei, Arial;";
        image_subheading.setAttribute("id", this.constant.PREFIX + this.constant.CODE + this.id);
        image_subheading.style.cssText = css + " bottom:" + (8 + offsetHeight) + "px; line-height:20px; height:20px; font-size:16px; color:gray; font-family:SimSun, Arial;";
        if(this.constant.VERTICAL != this.type)
        {
            this.parent.$A(image_heading, image);
            this.parent.$A(image_subheading, image);
        }
        this.parent.$A(image, panel);
        this.parent.$A(heading, panel);
        this.container = {container:panel, imageContainer:image, headingContainer:heading, imageHeading:image_heading, imageSubheading:image_subheading};
        panel.attachEvent("onmouseover", function(){slide.clearTimer();});
        panel.attachEvent("onmouseout", function(){slide.autoPlay();});
        if(!className){this.setInitStyle();}
    },
    /**
     * 创建元素
     * @param index 元素索引
     * @param bigImageSrc 大图片src
     * @param smallImageSrc 小图片src
     * @param heading 标题
     * @param subheading 副标题
     * @param link 链接
     * @param target 链接目标
     * @throws 参数错误
     * @throws 元素索引重复错误
     */
    createElement : function(index, bigImageSrc, smallImageSrc, heading, subheading, link, target)
    {
        if(7 != arguments.length)
        {
            throw new Error("参数错误, 参数个数应为7个, 实际为" + arguments.length);
        }
        if(null != this.indexMap.get(this.constant.INDEX + index))
        {
            throw new Error("重复的索引值; index = " + index);
        }
        smallImageSrc = smallImageSrc || bigImageSrc;
        target = target || "_blank";
        var slide = this;
        var container = this.container;
        var bigA = this.parent.$C("a");
        var bigI = this.parent.$C("img");
        var item = this.parent.$C("li");
        var smallA = this.parent.$C("a");
        var smallI = this.parent.$C("img");
        var itemHeading = this.parent.$C("dl");
        var h1 = this.parent.$C("dt");
        var h1A = this.parent.$C("a");
        var h2 = this.parent.$C("dd");
        var h2A = this.parent.$C("a");
        bigA.setAttribute("id", this.constant.PREFIX + this.constant.BIG_HREF + index);
        bigA.setAttribute("href", link);
        bigA.setAttribute("target", target);
        bigI.setAttribute("id", this.constant.PREFIX + this.constant.BIG_IMG + index);
        bigI.setAttribute("src", bigImageSrc);
        bigI.setAttribute("width", this.bigImage.width);
        bigI.setAttribute("height", this.bigImage.height);
        bigI.setAttribute("border", 0);
        item.setAttribute("id", this.constant.PREFIX + this.constant.SMALL_LI + index);
        item.style.cssText = "cursor:default;" + (this.constant.VERTICAL == this.type ? "height:" + this.smallImage.height + "px;" : "");
        smallA.setAttribute("id", this.constant.PREFIX + this.constant.SMALL_HREF + index);
        smallA.style.cssText = "display:block; width:" + this.smallImage.width + "px; height:" + this.smallImage.height + "px; float:left;"
        smallA.setAttribute("href", link);
        smallA.setAttribute("target", target);
        smallI.setAttribute("id", this.constant.PREFIX + this.constant.SMALL_IMG + index);
        smallI.setAttribute("src", smallImageSrc);
        smallI.setAttribute("width", this.smallImage.width);
        smallI.setAttribute("height", this.smallImage.height);
        smallI.setAttribute("border", 0);
        itemHeading.setAttribute("id", this.constant.PREFIX + this.constant.SMALL_DL + index);
        itemHeading.style.cssText = "float:left; display:block; width:" + (this.width - this.bigImage.width - this.smallImage.width - this.offsetMargin) + "px;height:" + this.smallImage.height + ";";
        h1.setAttribute("id", this.constant.PREFIX + this.constant.SMALL_DT + index);
        h1A.setAttribute("id", this.constant.PREFIX + this.constant.SMALL_DT_A + index);
        h1A.setAttribute("href", link);
        h1A.setAttribute("target", target);
        h1A.style.cssText = "margin-left:3px;font-weight:bold;font-size:14px;";
        h2.setAttribute("id", this.constant.PREFIX + this.constant.SMALL_DD + index);
        h2.style.cssText = "text-indent:3px; color:#888888;";
        if(this.constant.VERTICAL == this.type)
        {
            this.parent.$A(this.parent.$X(heading), h1A);
            this.parent.$A(this.parent.$X(subheading), h2);
            this.parent.$A(h1A, h1);
            this.parent.$A(h1, itemHeading);
            this.parent.$A(h2, itemHeading);
            this.parent.$A(smallI, smallA);
            this.parent.$A(smallA, item);
            this.parent.$A(itemHeading, item);
        }
        else
        {
            this.parent.$A(this.parent.$X(index), item);
        }
        this.parent.$A(bigI, bigA);
        this.parent.$A(bigA, container.imageContainer);
        this.parent.$A(item, container.headingContainer);
        this.indexMap.put(this.constant.INDEX + index, {sHeading:heading, sSubheading:subheading});
        item.attachEvent("onmouseover", function(){slide.play(index)});
    },

    /**
     * 清除定时器
     */
    clearTimer : function()
    {
        if(null != this.timer)
        {
            clearInterval(this.timer);
            this.timer = null;
        }
    },

    /**
     * 清除播放效果定时器
     */
    clearEffectTimer : function()
    {
        if(null != this.effectTimer)
        {
            clearInterval(this.effectTimer);
            this.effectTimer = null;
        }
    },

    /**
     * 自动播放
     */
    autoPlay : function()
    {
        var slide = this;
        var index = 0;
        this.timer = setInterval(function(){
            index = slide.current + 1;
            if(index >= slide.count)
            {
                index = 0;
            }
            slide.play(index);
        }, this.interval);
    },

    /**
     * 播放
     * @param index 索引
     */
    play : function(index)
    {
        if(index != this.current)
        {
            this.clearEffectTimer();
            var slide = this;
            var pre = this.current;
            var isVertical = (this.constant.VERTICAL == this.type);
            var tmpOffset = isVertical ? this.height : this.width;
            var offset = tmpOffset * index * -1;
            var speed = tmpOffset;
            var speed2 = tmpOffset * 0.2;
            var imageContainer = this.container.imageContainer;
            var style = imageContainer.style;
            var position = isVertical ? parseInt(style.marginTop, 10) : parseInt(style.marginLeft, 10);
            position = isNaN(position) ? 0 : position;
            this.current = index;
            this.setHeading(index);
            this.effectTimer = setInterval(function(){
                if(index < pre)
                {
                    if(Math.abs(position) - Math.abs(offset) > tmpOffset)
                    {
                        position = position + (speed2 * 1);
                    }
                    else
                    {
                        speed *= 0.45;
                        speed = Math.ceil(speed);
                        position = position + (speed * 1);
                    }
                    if(position >= offset)
                    {
                        slide.clearEffectTimer();
                        position = offset;
                    }
                }
                else if(index > pre)
                {
                    if(Math.abs(offset) - Math.abs(position) > tmpOffset)
                    {
                        position = position + (speed2 * -1);
                    }
                    else
                    {
                        speed *= 0.45;
                        speed = Math.ceil(speed);
                        position = position + (speed * -1);
                    }
                    if(position <= offset)
                    {
                        slide.clearEffectTimer();
                        position = offset;
                    }
                }
                if(isVertical)
                {
                    style.marginTop = position + "px";
                }
                else
                {
                    style.marginLeft = position + "px";
                }
            }, 1);
            this.setCurrentStyle(index);
        }
    },

    /**
     * 设置当前元素的样式
     * @param index 索引
     */
    setCurrentStyle : function(index)
    {
        for (var i = 0; i < this.count; i++)
        {
            this.parent.$E(this.constant.PREFIX + this.constant.SMALL_LI + i).className = "";
        }
        this.parent.$E(this.constant.PREFIX + this.constant.SMALL_LI + index).className = "current";
    },

    /**
     * 设置标题及副标题
     * @param index 索引
     */
    setHeading : function(index)
    {
        if(this.constant.VERTICAL != this.type)
        {
            var heading = this.indexMap.get(this.constant.INDEX + index);
            this.container.imageHeading.innerHTML = heading.sHeading;
            this.container.imageSubheading.innerHTML = heading.sSubheading;
        }
    },

    /**
     * 设置默认样式
     */
    setInitStyle : function()
    {
        var VSlide = ['div.VSlide{}',
                        'div.VSlide a{color:#FF3300; text-decoration:none;}',
                        'div.VSlide a:hover{text-decoration:underline;}',
                        'div.VSlide ul{display:block;}',
                        'div.VSlide ul li{list-style:none; margin-top:10px;}',
                        'div.VSlide .current{background:#EFEFEF;}'];
        var HSlide = ['div.HSlide{}',
                        'div.HSlide a{color:#FF3300; text-decoration:none;}',
                        'div.HSlide a:hover{text-decoration:underline;}',
                        'div.HSlide ul{display:block;}',
                        'div.HSlide ul li{list-style:none; height:16px; width:16px; text-align:center; line-height:16px; float:left; margin-right:5px; margin-top:1px; background:#0e58af;}',
                        'div.HSlide .current{background:#FF6600;}'];
        var cssTexts = this.constant.VERTICAL == this.type ? VSlide : HSlide;
        this.parent.dynamicStyle(cssTexts);
    },

    /**
     * 显示面板
     * @param target 目录位置
     */
    showPanel : function(target)
    {
        if("string" == typeof(target))
        {
            this.parent.$A(this.container.container, this.parent.$E(target));
        }
        else
        {
            this.parent.$A(this.container.container, target);
        }
        this.setHeading(0);
        this.setCurrentStyle(0);
        this.autoPlay();
    }
};
/**
 * UI组件
 * @version 1.0
 */
function UIComponent()
{
    this.prefix = "RIAClient_UIComponet_";
    this.parent = RIAClient;
    this.config = {
        dialog : {
            $pre_style : null,
            $dialog_win : null,
            $first_btn : null,
            $pre_btn : null,
            bgcolor : {
                title : "#25b7e8",
                body : "#f6fbfe",
                button : "#b3d4f0"
            },
            border_color : {
                outer : "#005195",
                inner : "#9ef9ff",
                context : "#0fa0db",
                button : "#c2dcf1"
            },
            id : "Dialog",
            is_drag : true,
            width : 400,
            height : "auto",
            title : "",
            context : "",
            op_buttons : [
                {op:"CLOSE", handler:null, args:[]}
            ],
            func_buttons : [
                {label:"确定", handler:null, args:[], enabled:true},
                {label:"取消", handler:null, args:[], enabled:true}
            ]
        }
    };
}
/**
 * 事件分发器
 */
var Dispatcher = {
    /**
     * 分发一个事件
     * @param target 事件源
     * @param eventType 事件类型 onxxxx
     * @param datatype 事件属性
     * @param data 事件属性
     */
    dispatchEvent : function(target, eventType, datatype, data)
    {
        var obj = RIAClient.$E(target);
        var e = null;
        if(document.createEvent)
        {
            e = document.createEvent("Events");
            e.initEvent(eventType.substr(2), true, false);
        }
        else if(document.createEventObject)
        {
            e = document.createEventObject();
        }
        else
        {
            return false;
        }
        e.datatype = datatype;
        e.data = data;
        if(obj.dispatchEvent)
        {
            obj.dispatchEvent(e);
        }
        else if(obj.fireEvent)
        {
            obj.fireEvent(eventType, e);
        }
    }
};
/**
 * 下拉框构告函数
 * border:#7F9DB9/bgcolor:#316AC5
 */
function JSelect()
{
    //attributes
    this.$name = null;
    this.$id = null;
    this.width = 128;
    this.height = 20;
    this.optionHeight = 20;
    //events
    this.$events = {
        $onchange : null,
        $onclick : null,
        $ondblclick : null,
        $onmouseover : null,
        $onmouseout : null,
        $onmousedown : null,
        $onmousemove : null,
        $onfocus : null,
        $onblur : null,
        $onkeyup : null,
        $onkeydown : null,
        $onkeypress : null
    };
    //------------------------
    this.$selectedIndex = 0;
    this.$value = null;
    this.$text = null;
    this.$defaultSelected = false;
    this.$selected = false;
    this.$disabled = false;
    this.$options = [];
    this.$lastIndex = -1;
    //------------------------
    this.$select = null;
    this.$htmlSelect = null;
    //------------------------
    this.$parent = RIAClient;
}
JSelect.prototype = {
    /**
     * 添加事件监听
     */
    addEventHandler : function()
    {
        var events = this.$events;
        if(null != this.$select)
        {
            for(var e in events)
            {
                if(null != events[e])
                {
                    this.$select.attachEvent(e.substr(1), events[e]);
                    if("$onchange" == e && "MSIE" == Browser.type)
                    {
                        this.$select.attachEvent("onpropertychange", events[e]);
                    }
                }
            }
        }
    },
    /**
     * 移除事件监听
     */
    removeEventHandler : function()
    {
        var events = this.$events;
        if(null != this.$select)
        {
            for(var e in events)
            {
                if(null != events[e])
                {
                    this.$select.detachEvent(e.substr(1), events[e]);
                    if("$onchange" == e && "MSIE" == Browser.type)
                    {
                        this.$select.detachEvent("onpropertychange", events[e]);
                    }
                }
            }
        }
    },
    /**
     * 创建select元素
     * @return object sel
     */
    crateHTMLSelectElement : function()
    {
        var sel = null;
        if("MSIE" == Browser.type)
        {
            sel = this.$parent.$C('<select name="'+this.$name+'">');
        }
        else
        {
            sel = this.$parent.$C("select");
            sel.setAttribute("name", this.$name);
        }
        sel.setAttribute("id", "html_sel_" + this.$id);
        sel.style.cssText = "display:none";
        this.$htmlSelect = sel;
        return sel;
    },
    /**
     * 下拉箭头事件
     */
    arrowMouseEvent : function(hover)
    {
        var arrow = this.$parent.$E("sel_arrow_" + this.$id);
        if(hover)
        {
            arrow.className = "ria-sel-ahover";
        }
        else
        {
            arrow.className = "";
        }
        arrow = null;
    },
    /**
     * 当前值事件
     */
    curMouseEvent : function(isFocus)
    {
        var item = this.$parent.$E("sel_cur_" + this.$id);
        if(isFocus)
        {
            item.className = "selected";
        }
        else
        {
            item.className = "";
        }
        item = null;
    },
    /**
     * 创建虚拟的下拉框
     * @return object sel
     */
    createVirtualSelect : function()
    {
        var sel = this.$parent.$C("div");
        var item = this.$parent.$C("a");
        var arrow = this.$parent.$C("code");
        var _this = this;
        sel.setAttribute("id", this.$id);
        sel.className = "ria-select";
        item.setAttribute("id", "sel_cur_" + this.$id);
        item.setAttribute("href", "javascript:void(0);");
        arrow.setAttribute("id", "sel_arrow_" + this.$id);
        arrow.attachEvent("onmouseover", function(){_this.arrowMouseEvent(true);});
        arrow.attachEvent("onmousedown", function(){_this.arrowMouseEvent(true);});
        arrow.attachEvent("onmouseout", function(){_this.arrowMouseEvent(false);});
        arrow.attachEvent("onmouseup", function(){_this.arrowMouseEvent(false);});
        item.attachEvent("onfocus", function(){_this.curMouseEvent(true);});
        item.attachEvent("onblur", function(){_this.curMouseEvent(false);});
        item.attachEvent("onfocusout", function(){_this.curMouseEvent(false);});
        if(!this.$disabled)
        {
            sel.attachEvent("onclick", function(){_this.showOptions(true)});
        }
        this.$parent.$A(item, sel);
        this.$parent.$A(arrow, sel);
        this.$select = sel;
        return sel;
    },
    /**
     * 创建区域面板
     * @return object panel
     */
    createPanel : function()
    {
        var panel = this.$parent.$C("div");
        var optionPanel = this.$parent.$C("div");
        var htmlSel = this.crateHTMLSelectElement();
        var sel = this.createVirtualSelect();
        var iframe = '<iframe frameborder="0" scrolling="no" vspace="0" hspace="0" marginwidth="0" marginheight="0"></iframe>';
        panel.setAttribute("id", "sel_panel_" + this.$id);
        optionPanel.setAttribute("id", "sel_optionPanel_" + this.$id);
        panel.className = "ria-select-panel";
        optionPanel.className = "ria-select-optionPanel";
        optionPanel.innerHTML = iframe;
        optionPanel.attachEvent("onmouseup", function(){window.event.returnValue = false; window.event.cancelBubble = true;});
        this.$parent.$A(htmlSel, panel);
        this.$parent.$A(sel, panel);
        this.$parent.$A(optionPanel, panel);
        return panel;
    },
    /**
     * 显示option
     */
    showOptions : function(isShow)
    {
        var o = this.$parent.$E("sel_optionPanel_" + this.$id);
        if(null != o && false == this.$disabled)
        {
            var _this = this;
            if(isShow)
            {
                this.setOptionPanelPos();
                o.style.display = "block";
                document.attachEvent("onmouseup", function(){
                    _this.showOptions(false);
                });
            }
            else
            {
                o.style.display = "none";
            }
        }
        o = null;
    },
    /**
     * 设置事件句柄
     */
    setEventHandler : function(events)
    {
        var evts = events || {};
        for(var e in evts)
        {
            this.$events[e] = evts[e];
        }
    },
    /**
     * 设置属性
     */
    setAttributes : function(attrs)
    {
        var ats = attrs || {};
        for(var i in ats)
        {
            this[i] = ats[i];
        }
    },
    /**
     * 设置下拉框属性
     */
    setSelectAttribute : function()
    {
        var w = this.width;
        var h = this.height;
        var oh = this.optionHeight;
        var cssTexts = [
            '.ria-select-panel{border:1px solid #7F9DB9; margin:0px; padding:1px; width:'+(w-2)+'px; height:'+(h-2)+'px; display:-moz-inline-stack; display:inline-block; zoom:1; *display:inline;}',
            '.ria-select-panel a{text-decoration:none; color:black; display:block; background-color:white; text-indent:3px; cursor:default;}',
            '.ria-select-panel a.selected{background-color:#316AC5; color:white; display:block; text-indent:3px; cursor:default;}',
            '.ria-select-panel .ria-select{width:'+(w-2)+'px; height:'+(h-2)+'px;}',
            '.ria-select-panel .ria-select a{display:block; width:'+(w-18)+'px; height:'+(h-2)+'px; line-height:'+(h-2)+'px; margin:0px 1px 0px 0px; float:left; font-size:12px; }',
            '.ria-select-panel .ria-select code{display:block; width:15px; height:17px; float:left; background:transparent url("images/Select_Arrow.gif") no-repeat 0 0; font-size:1px; line-height:1px;}',
            '.ria-select-panel .ria-select code.ria-sel-ahover{background-position:0px -17px;}',
            '.ria-select-panel .ria-select-optionPanel{position:absolute; width:'+w+'px; height:auto; border:1px solid #7F9DB9; z-index:3000; display:none; background-color:white;}',
            '.ria-select-panel .ria-select-optionPanel iframe{position:absolute; z-index:-1; width:100%; height:100%; filter:alpha(opacity=0); -moz-opacity:.00; opacity:.00;}',
            '.ria-select-panel .ria-select-optionPanel a.ria-select-option{display:block; width:'+(w-2)+'px; height:'+oh+'px; line-height:'+oh+'px; text-indent:2px; background-color:white;}'
        ];
        this.$parent.dynamicStyle(cssTexts);
    },
    /**
     * 设置options面板的位置
     */
    setOptionPanelPos : function()
    {
        var ref = this.$parent.$E(this.$id);
        var pos = this.$parent.getPosition(ref);
        var ops = this.$parent.$E("sel_optionPanel_" + this.$id);
        ops.style.left = (pos.x - 2) + "px";
        ops.style.top = (pos.y + this.height) + "px";
        ref = null;
        pos = null;
        ops = null;
    },
    /**
     * 创建
     */
    create : function(htmlFor)
    {
        var panel = this.createPanel();
        var _for = this.$parent.$E(htmlFor);
        this.setSelectAttribute();
        this.$parent.$A(panel, _for);
        this.addEventHandler();
        return this;
    },
    /**
     * 添加一个option
     */
    add : function(option)
    {
        var item = null;
        var _this = this;
        option.index = this.$options.length;
        option.fixedIndex = ++this.$lastIndex;
        option.$select = this;
        this.$options.push(option);
        this.$htmlSelect.options[this.$htmlSelect.options.length] = new Option(option.text, option.value, option.defaultSelected, option.selected);
        this.$parent.$A(option.getItem(this.$id), this.$parent.$E("sel_optionPanel_" + this.$id));
    },
    /**
     * 删除option
     */
    remove : function(index)
    {
        this.$htmlSelect.remove(index);
        var option = this.$parent.$E("sel_option_" + this.id + "_" + this.$options[index].fixedIndex);
        if(null != option)
        {
            this.$parent.$D(option, this.$parent.$E("sel_optionPanel_" + this.id));
            this.$options.splice(index, 1);
            this.updateOption();
        }
        if(this.$options.length <= 0)
        {
            this.$lastIndex = -1;
        }
        option = null;
    },
    /**
     * 更新option
     */
    updateOption : function()
    {
        var size = this.$options.length;
        var option = null;
        for(var i = 0; i < size; i++){
            option = this.$options[i];
            option.index = i;
        }
    },
    /**
     * 设置完成
     */
    done : function()
    {
        var size = this.$options.length;
        var option = null;
        var defOption = null;
        var selOption = null;
        var curOption = this.$parent.$E("sel_cur_" + this.$id);
        var defIndex = 0;
        var selIndex = 0;
        for(var i = 0; i < size; i++)
        {
            option = this.$options[i];
            if(option.defaultSelected)
            {
                defOption = option;
                defIndex = i;
            }
            if(option.selected)
            {
                selOption = option;
                selIndex = i;
            }
        }
        if(defOption == selOption && (null != defOption && null != selOption))
        {
            curOption.innerHTML = defOption.text;
            curOption.className = "selected";
            curOption.focus();
            this.$value = defOption.value;
            this.$text = defOption.text;
            this.$defaultSelected = defOption.defaultSelected;
            this.$selected = defOption.selected;
            this.$selectedIndex = defIndex;
            this.$htmlSelect.selectedIndex = defIndex;
        }
        else
        {
            if(null != selOption)
            {
                curOption.innerHTML = selOption.text;
                curOption.className = "selected";
                curOption.focus();
                this.$value = selOption.value;
                this.$text = selOption.text;
                this.$defaultSelected = selOption.defaultSelected;
                this.$selected = selOption.selected;
                this.$selectedIndex = selIndex;
                this.$htmlSelect.selectedIndex = selIndex;
            }
            else if(null != defOption)
            {
                curOption.innerHTML = defOption.text;
                this.$value = defOption.value;
                this.$text = defOption.text;
                this.$defaultSelected = defOption.defaultSelected;
                this.$selected = defOption.selected;
                this.$selectedIndex = defIndex;
                this.$htmlSelect.selectedIndex = defIndex;
            }
            else
            {
                if(size > 0)
                {
                    curOption.innerHTML = this.$options[0].text;
                    this.$value = this.$options[0].value;
                    this.$text = this.$options[0].text;
                    this.$defaultSelected = this.$options[0].defaultSelected;
                    this.$selected = this.$options[0].selected;
                    this.$selectedIndex = 0;
                    this.$htmlSelect.selectedIndex = 0;
                }
            }
        }
        option = null;
        defOption = null;
        selOption = null;
        curOption = null;
    }
};
function JOption(text, value, defaultSelected, selected)
{
    this.text = text;
    this.value = value;
    this.defaultSelected = typeof(defaultSelected) == "boolean" ?  defaultSelected : false;
    this.selected = typeof(selected) == "boolean" ? selected : false;
    this.index = -1;
    this.fixedIndex = -1;
    this.$select = null;
    this.$parent = RIAClient;
}
JOption.prototype = {
    /**
     * 获取Node
     */
    getItem : function(id)
    {
        var option = this.$parent.$C("a");
        var _this = this;
        option.className = "ria-select-option";
        option.setAttribute("id", "sel_option_" + id + "_" + this.fixedIndex);
        option.setAttribute("value", this.value);
        option.setAttribute("defaultSelected", this.defaultSelected);
        option.setAttribute("selected", this.selected);
        option.setAttribute("href", "javascript:void(0);");
        option.innerHTML = this.text;
        option.attachEvent("onmouseover", function(){_this.hover(id)});
        option.attachEvent("onmouseout", function(){_this.hout(id)});
        option.attachEvent("onclick", function(){_this.setSelectValue();});
        return option;
    },
    /*
     * 设置select值
     */
    setSelectValue : function()
    {
        var curOption = this.$parent.$E("sel_cur_" + this.$select.$id);
        var oldText = curOption.innerHTML;
        this.$select.$value = this.value;
        this.$select.$text = this.text;
        this.$select.$defaultSelected = this.defaultSelected;
        this.$select.$selected = this.selected;
        this.$select.$selectedIndex = this.index;
        this.$select.$htmlSelect.selectedIndex = this.index;
        curOption.innerHTML = this.text;
        curOption.focus();
        this.$select.showOptions(false);
        if(oldText != this.text)
        {
            if("MSIE" == Browser.type)
            {
                Dispatcher.dispatchEvent(this.$select.$id, "onpropertychange", "change", "change");
            }
            else
            {
                Dispatcher.dispatchEvent(this.$select.$id, "onchange", "change", "change");
            }
        }
    },
    /**
     * 鼠标移上去的效果
     */
    hover : function(id)
    {
        var option = null;
        try
        {
            option = this.$parent.$E("sel_option_" + id + "_" + this.fixedIndex);
            option.className = "selected";
            option.focus();
        }
        catch(e){}finally{option = null;}
    },
    /**
     * 鼠标移开的效果
     */
    hout : function(id)
    {
        var option = this.$parent.$E("sel_option_" + id + "_" + this.fixedIndex);
        option.className = "";
        option = null;
    }
};
UIComponent.prototype = {
    /**
     * 重置UI遮罩层
     * @param id
     */
    $reset_ui_mask : function(id)
    {
        var doc = this.parent.getDocumentSize();
        var mask = this.parent.$E("ria_ui_mask_" + id);
        var ifr = this.parent.$E("ria_ui_mask_" + id + "_iframe");
        var div = this.parent.$E("ria_ui_mask_" + id + "_div");
        if(null != mask){
            mask.style.width = doc.width + "px";
            mask.style.height = doc.height + "px";
            ifr.style.width = doc.width + "px";
            ifr.style.height = doc.height + "px";
            div.style.width = doc.width + "px";
            div.style.height = doc.height + "px";
        }
    },
    /**
     * 遮罩层
     * @param id
     * @return dom
     */
    $ui_mask : function(id)
    {
        var mask = this.parent.$E("ria_ui_mask_" + id);
        var doc = this.parent.getDocumentSize();
        if(null == mask)
        {
            mask = this.parent.$C("div");
            mask.setAttribute("id", "ria_ui_mask_" + id);
            mask.style.cssText = "display:none; position:absolute; left:0px; top:0px;width:"+doc.width+"px; height:"+doc.height+"px; z-index:10000;";
            mask.innerHTML = '<iframe id="ria_ui_mask_' + id + '_iframe" style="position:absolute; z-index:-1; left:0px; top:0px; filter:alpha(opacity=0); -moz-opacity:.00; opacity:.00; width:'+doc.width+'px; height:'+doc.height+'px" frameborder="no" src="about:blank"></iframe><div id="ria_ui_mask_' + id + '_div" style="filter:alpha(opacity=10); -moz-opacity:.10; opacity:.10; background:#000; width:'+doc.width+'px; height:'+doc.height+'px"></div>';
            this.parent.$A(mask);
        }
        else
        {
            this.$reset_ui_mask(id);
        }
        return mask;
    },
    /**
     * 设置参数
     * @param param 对话框配置信息
     */
    $dialog_set : function(param)
    {
        if(param.bgclor)
        {
            this.config.dialog.bgcolor.title = param.bgcolor.title || this.config.dialog.bgcolor.title;
            this.config.dialog.bgcolor.body = param.bgcolor.body || this.config.dialog.bgcolor.body;
            this.config.dialog.bgcolor.button = param.bgcolor.button || this.config.dialog.bgcolor.button;
        }
        if(param.border_color)
        {
            this.config.dialog.border_color.outer = param.border_color.outer || this.config.dialog.border_color.outer;
            this.config.dialog.border_color.inner = param.border_color.inner || this.config.dialog.border_color.inner;
            this.config.dialog.border_color.context = param.border_color.context || this.config.dialog.border_color.context;
            this.config.dialog.border_color.button = param.border_color.button || this.config.dialog.border_color.button;
        }
        this.config.dialog.id = param.id || this.config.dialog.id;
        this.config.dialog.width = param.width || this.config.dialog.width;
        this.config.dialog.height = param.height || this.config.dialog.height;
        this.config.dialog.title = param.title || this.config.dialog.title;
        this.config.dialog.context = param.context || this.config.dialog.context;
        this.config.dialog.op_buttons = param.op_buttons || this.config.dialog.op_buttons;
        this.config.dialog.func_buttons = param.func_buttons || this.config.dialog.func_buttons;
    },
    /**
     * 获取对话框大小
     */
    $getDialogSize : function(offsetWidth, offsetHeight)
    {
        var _w = (this.config.dialog.width - offsetWidth) + "px";
        var _h = typeof(this.config.dialog.height) == "number" ? (this.config.dialog.height - offsetHeight) + "px" : "auto";
        return {width : _w, height : _h};
    },
    /**
     * 设置对话框样式
     */
    $setDialogStyle : function()
    {
        var title_height = 30;
        var button_height = 25;
        var title_offset_h = 7;
        var title_offset_w = 5;
        var bottom_offset_h = 6;
        var bottom_offset_w = 6;
        var op_buttons = this.config.dialog.op_buttons;
        var size = op_buttons.length;
        var op_btns_width = size == 1 ? 42 : (size == 2 ? 67 : 93);
        var border_color = this.config.dialog.border_color;
        var bgcolor = this.config.dialog.bgcolor;
        var frame = this.$getDialogSize(0, 0);
        var title = this.$getDialogSize(title_offset_w, 0);
        var outer = this.$getDialogSize(2, title_height + bottom_offset_h);
        var inner = this.$getDialogSize(4, title_height + bottom_offset_h);
        var context = this.$getDialogSize(10, title_height + bottom_offset_h + 32);
        var bottom = this.$getDialogSize(6, 0);
        var cssTexts = [
            '.ria-frame{position:relative; width:' + frame.width + '; height:' + frame.height + '; font:normal normal normal 12px/16px Arail,Verdana,Tahoma,"宋体"; overflow:hidden;}',
            '.ria-frame .ria-title{width:' + frame.width + '; height:' + title_height + 'px; overflow:hidden;}',
            '.ria-frame .ria-title-top{width:' + frame.width + '; height:' + title_offset_h + 'px;}',
            '.ria-frame .ria-title-l{width:' + title.width + '; height:' + title_offset_h + 'px; background:transparent url(images/UI_Dialog.png) no-repeat 0 0; float:left; font-size:0px; line-height:0px;}',
            '.ria-frame .ria-title-r{width:' + title_offset_w + 'px; height:' + title_offset_h + 'px; background:transparent url(images/UI_Dialog.png) no-repeat 0 -183px; float:left; font-size:0px; line-height:0px;}',
            '.ria-frame .ria-title-text-lr{width:' + outer.width + '; height:' + (title_height - title_offset_h) + 'px; border:1px solid ' + border_color.outer + '; border-top:none; border-bottom:none;}',
            '.ria-frame h2{width:' + inner.width + '; height:' + (title_height - title_offset_h) + 'px; display:block; background-color:' + bgcolor.title + '; font:normal normal bold 12px/22px Arail,Verdana,Tahoma,"宋体"; text-indent:6px; color:white; border:1px solid ' + border_color.inner + '; border-top:none; border-bottom:none; margin:0px; padding:0px;}',
            '.ria-frame .ria-frame-func{position:absolute; right:7px; top:0px; height:18px; width:93px;}',
            '.ria-frame .ria-frame-op{display:block; height:18px; width:' + op_btns_width + 'px; float:right; margin:0px; padding:0px;}',
            '.ria-frame .ria-frame-op li{list-style:none; float:left; display:block; width:42px; height:18px; overflow:hidden;}',
            '.ria-frame .ria-frame-op li a{display:block; width:100%; height:100%; text-indent:-10000px; background:transparent url(images/UI_Dialog.png) no-repeat 0 -125px; outline:none;}',
            '.ria-frame .ria-frame-op li a:hover{background-position:0 -144px;}',
            '.ria-frame .ria-frame-op li a:active{background-position:0 -163px;}',
            '.ria-frame .ria-frame-op li.ria-frame-min{width:25px;}',
            '.ria-frame .ria-frame-op li.ria-frame-min a{background-position:-43px -125px;}',
            '.ria-frame .ria-frame-op li.ria-frame-min a:hover{background-position:-43px -144px;}',
            '.ria-frame .ria-frame-op li.ria-frame-min a:active{background-position:-43px -163px;}',
            '.ria-frame .ria-frame-op li.ria-frame-max{width:26px;}',
            '.ria-frame .ria-frame-op li.ria-frame-max a{background-position:-68px -125px;}',
            '.ria-frame .ria-frame-op li.ria-frame-max a:hover{background-position:-68px -144px;}',
            '.ria-frame .ria-frame-op li.ria-frame-max a:active{background-position:-68px -163px;}',
            '.ria-frame .ria-frame-op li.ria-frame-ret{width:26px;}',
            '.ria-frame .ria-frame-op li.ria-frame-ret a{background-position:-94px -125px;}',
            '.ria-frame .ria-frame-op li.ria-frame-ret a:hover{background-position:-94px -144px;}',
            '.ria-frame .ria-frame-op li.ria-frame-ret a:active{background-position:-94px -163px;}',
            '.ria-frame .ria-frame-op li.ria-frame-close{width:42px;}',
            '.ria-frame .ria-frame-op li.ria-frame-close a{background-position:-120px -125px;}',
            '.ria-frame .ria-frame-op li.ria-frame-close a:hover{background-position:-120px -144px;}',
            '.ria-frame .ria-frame-op li.ria-frame-close a:active{background-position:-120px -163px;}',
            '.ria-frame .ria-body{width:' + outer.width + '; height:' + outer.height + '; border:1px solid ' + border_color.outer + '; border-top:none; border-bottom:none; background-color:' + bgcolor.body + ';}',
            '.ria-frame .ria-body-inner{width:' + inner.width + '; height:' + outer.height + '; display:block; border:1px solid ' + border_color.inner + '; border-top:none; border-bottom:none;}',
            '.ria-frame .ria-body-context{width:' + context.width + '; height:' + context.height + '; padding:2px 3px; border-top:1px solid ' + border_color.context + ';}',
            '.ria-frame .ria-button-area{padding-top:1px; border-top:1px solid ' + border_color.button + ';}',
            '.ria-frame .ria-button-line{height:21px; padding-top:4px; text-align:right; width:' + inner.width + '; background-color:#b3d4f0; overflow:hidden;}',
            '.ria-frame .ria-button-line a{'+(window.opera ? 'display:inline-block;' : 'display:-moz-inline-stack; display:inline-block; zoom:1; *display:inline;')+' width:auto; height:21px; line-height:21px; background:transparent url(images/UI_Dialog.png) no-repeat 100% -15px; padding-right:4px; text-decoration:none; color:#001c30; cursor:default; margin-right:6px; outline:none;}',
            '.ria-frame .ria-button-line a button{border:none; height:21px; text-align:center; padding:0px 10px 0px 15px; background:transparent url(images/UI_Dialog.png) no-repeat -0 -15px;}',
            '.ria-frame .ria-button-line .ria-button-focus{background-position:100% -37px;}',
            '.ria-frame .ria-button-line .ria-button-focus button{background-position:0 -37px;}',
            '.ria-frame .ria-button-line .ria-button-over{background-position:100% -103px;}',
            '.ria-frame .ria-button-line .ria-button-over button{background-position:0 -103px;}',
            '.ria-frame .ria-button-line .ria-button-down{background-position:100% -81px;}',
            '.ria-frame .ria-button-line .ria-button-down button{background-position:0 -81px;}',
            '.ria-frame .ria-button-line .ria-button-dis{background-position:100% -59px; color:#5f7b91}',
            '.ria-frame .ria-button-line .ria-button-dis button{background-position:0 -59px; color:#5f7b91}',
            '.ria-frame .ria-frame-bottom{width:' + frame.width + '; height:' + bottom_offset_h + 'px; font-size:0px; line-height:0px;}',
            '.ria-frame .ria-frame-bottom-l{width:' + bottom.width + '; height:' + bottom_offset_h + 'px; background:transparent url(images/UI_Dialog.png) no-repeat 0 -8px; float:left; font-size:0px; line-height:0px;}',
            '.ria-frame .ria-frame-bottom-r{width:' + bottom_offset_w + 'px; height:' + bottom_offset_h + 'px; background:transparent url(images/UI_Dialog.png) no-repeat -6px -184px; float:left; font-size:0px; line-height:0px;}'
        ];
        if(null != this.config.dialog.$pre_style)
        {
            this.parent.$D(this.config.dialog.$pre_style, this.parent.$T("head")[0]);
        }
        this.config.dialog.$pre_style = this.parent.dynamicStyle(cssTexts);
    },
    /**
     * 对话框是否存在
     * @return true/false
     */
    $is_exist_dialog : function()
    {
        var frame = this.parent.$E(this.prefix + this.config.dialog.id);
        return (null != frame);
    },
    /**
     * 设置焦点
     */
    $dialog_set_focus : function()
    {
        if(this.$is_exist_dialog())
        {
            try{
                this.parent.$E(this.prefix + this.config.dialog.id).focus();
            }catch(e){}
        }
    },
    /**
     * 建立框架
     * @param 返回框架对象
     */
    $dialog_create_frame : function()
    {
        var pFrame = this.parent.$C("div");
        var frame = this.parent.$C("div");
        pFrame.style.cssText = "position:absolute; left:0px; top:0px;";
        pFrame.setAttribute("id", this.prefix + this.config.dialog.id);
        frame.className = "ria-frame";
        this.parent.$A(frame, pFrame);
        return frame;
    },
    /**
     * 拖动
     */
    $dailog_drag : function()
    {
        this.parent.drag(this.prefix + this.config.dialog.id);
    },
    /**
     * 建立标题栏
     * @return 标题栏
     */
    $dialog_create_titlebar : function()
    {
        var id_prefix = this.prefix + this.config.dialog.id;
        var titleBar = this.parent.$C("div");
        var topBar = this.parent.$C("div");
        var titleText = this.parent.$C("div");
        var h2 = this.parent.$C("h2");
        var topStr = '<div class="ria-title-l"></div><div class="ria-title-r"></div>';
        var _this = this;
        topBar.className = "ria-title-top";
        topBar.innerHTML = topStr;
        titleBar.className = "ria-title";
        titleText.className = "ria-title-text-lr";
        h2.className = "ria-title-text";
        titleBar.setAttribute("id", id_prefix + "_title");
        h2.setAttribute("id", id_prefix + "_title_text");
        this.parent.$A(h2, titleText);
        this.parent.$A(topBar, titleBar);
        this.parent.$A(titleText, titleBar);
        if(this.config.dialog.is_drag)
        {
            titleBar.attachEvent("onmousedown", function(){
                _this.$dailog_drag();
            });
        }
        return titleBar;
    },
    /**
     * 建立单个操作按钮
     * @param button 按钮属性对象
     * @return 按钮
     */
    $dialog_get_op_button : function(button, size)
    {
        var id_prefix = this.prefix + this.config.dialog.id;
        var btn = this.parent.$C("li");
        var link = this.parent.$C("a");
        var _this = this;
        link.setAttribute("href", "###");
        link.setAttribute("hidefocus", "true");
        if(size > 1)
        {
            btn.className = "ria-frame-" + (button.op).toLowerCase();
        }
        btn.setAttribute("id", id_prefix + "_" + button.op);
        if("MIN" == button.op)
        {
            btn.attachEvent("onclick", function(){_this.$dialog_op_min();});
        }
        else if("MAX" == button.op)
        {
            btn.attachEvent("onclick", function(){_this.$dialog_op_max();});
        }
        else
        {
            btn.attachEvent("onclick", function(){_this.$dialog_op_close();});
        }
        link.innerHTML = button.op;
        this.parent.$A(link, btn);
        return btn;
    },
    /**
     * 建立操作按钮[MIN|MAX|CLOSE]
     * @return 操作按钮
     */
    $dialog_create_op_buttons : function()
    {
        var op_buttons = this.config.dialog.op_buttons;
        var size = op_buttons.length;
        if(size > 0)
        {
            var id_prefix = this.prefix + this.config.dialog.id;
            var func = this.parent.$C("div");
            var op = this.parent.$C("ul");
            var button = null;
            func.className = "ria-frame-func";
            op.className = "ria-frame-op";
            op.setAttribute("id", id_prefix + "_op");
            for(var i = 0; i < size; i++)
            {
                button = op_buttons[i];
                this.parent.$A(this.$dialog_get_op_button(button, size), op);
            }
            this.parent.$A(op, func);
            return func;
        }
        return null;
    },
    /**
     * 获取操作按钮
     * @param op 操作按钮名[MIN|MAX|CLOSE]
     * @return 按钮
     */
    $get_op_button : function(op)
    {
        var op_buttons = this.config.dialog.op_buttons;
        var size = op_buttons.length;
        var button = null;
        for(var i = 0; i < size; i++)
        {
            button = op_buttons[i];
            if(button.op == op)
            {
                return button;
            }
        }
        return null;
    },
    /**
     * 关闭对话框
     */
    $dialog_op_close : function()
    {
        this.$dialog_set_focus();
        var btn = this.$get_op_button("CLOSE");
        this.dialog_close();
        if(null != btn && null != btn.handler)
        {
            btn.handler.apply(null, btn.args);
        }
    },
    /**
     * 最小化对话框
     */
    $dialog_op_min : function()
    {
        this.$dialog_set_focus();
        var btn = this.$get_op_button("MIN");
        if(null != btn && null != btn.handler)
        {
            btn.handler.apply(null, btn.args);
        }
    },
    /**
     * 最大化/还原对话框
     */
    $dialog_op_max : function()
    {
        this.$dialog_set_focus();
        var btn = this.$get_op_button("MAX");
        if(null != btn && null != btn.handler)
        {
            btn.handler.apply(null, btn.args);
        }
    },
    /**
     * 对话框内容区
     * @return 内容区域对象
     */
    $dialog_body : function()
    {
        var id_prefix = this.prefix + this.config.dialog.id;
        var body = this.parent.$C("div");
        var inner = this.parent.$C("div");
        var context = this.parent.$C("div");
        var btn_area = this.parent.$C("div");
        var btn_line = this.parent.$C("div");
        body.className = "ria-body";
        inner.className = "ria-body-inner";
        context.className = "ria-body-context";
        btn_area.className = "ria-button-area";
        btn_line.className = "ria-button-line";
        context.setAttribute("id", id_prefix + "_context");
        btn_area.setAttribute("id", id_prefix + "_btn_area");
        btn_line.setAttribute("id", id_prefix + "_btn_line");
        this.parent.$A(btn_line, btn_area);
        this.parent.$A(context, inner);
        this.parent.$A(btn_area, inner);
        this.parent.$A(inner, body);
        return body;
    },
    /**
     * 对话框底部
     * @return object
     */
    $dialog_bottom : function()
    {
        var bottom = this.parent.$C("div");
        bottom.className = "ria-frame-bottom";
        bottom.innerHTML = '<div class="ria-frame-bottom-l"></div><div class="ria-frame-bottom-r"></div>';
        return bottom;
    },
    /**
     * 关闭对话框
     */
    dialog_close : function()
    {
        if(null != this.config.dialog.$dialog_win)
        {
            this.config.dialog.$dialog_win.style.display = "none";
        }
    },
    /**
     * 显示对话框
     */
    dialog_show : function()
    {
        if(null != this.config.dialog.$dialog_win)
        {
            this.config.dialog.$dialog_win.style.display = "block";
        }
    },
    /**
     * 建立功能按钮
     * @param btn
     * @return dom
     */
    $dialog_create_func_btn : function(btn)
    {
        var a = this.parent.$C("a");
        var bt = this.parent.$C("button");
        var _this = this;
        var is_mouse = false;
        var def_cls = "";
        a.setAttribute("href", "###");
        a.setAttribute("hidefocus", "true");
        bt.innerHTML = btn.label;
        if(!btn.enabled)
        {
            a.className = 'ria-button-dis';
            bt.disabled = true;
        }
        else
        {
            a.attachEvent("onclick", function(){
                if(null != btn.handler)
                {
                    btn.handler.apply(null, args);
                }
                else
                {
                    _this.dialog_close();
                }
            });
            a.attachEvent("onmouseover", function(){
                def_cls = a.className;
                a.className = "ria-button-over";
                is_mouse = false;
            });
            a.attachEvent("onmouseout", function(){
                a.className = def_cls;
                is_mouse = false;
            });
            a.attachEvent("onmousedown", function(){
                def_cls = "ria-button-focus";
                a.className = "ria-button-down";
                is_mouse = true;
                if(null != _this.config.dialog.$pre_btn)
                {
                    _this.config.dialog.$pre_btn.className = "";
                }
                _this.config.dialog.$pre_btn = a;
            });
            a.attachEvent("onmouseup", function(){
                a.className = "ria-button-focus";
                is_mouse = false;
            });
            a.attachEvent("onfocus", function(){
                if(!is_mouse)
                {
                    a.className = "ria-button-focus";
                }
            });
            a.attachEvent("onblur", function(){
                a.className = "";
            });
            a.attachEvent("onfocusout", function(){
                a.className = "";
            });
        }
        this.parent.$A(bt, a);
        return a;
    },
    /**
     * 设置对话框数据
     */
    $set_dialog_data : function()
    {
        var id_prefix = this.prefix + this.config.dialog.id;
        var title = this.parent.$E(id_prefix + "_title_text");
        var context = this.parent.$E(id_prefix + "_context");
        var txtHeight = parseInt(this.parent.getOuterStyle(".ria-frame .ria-body-context", "height"), 10);
        var btn_area = this.parent.$E(id_prefix + "_btn_area");
        var btn_link = this.parent.$E(id_prefix + "_btn_line");
        var func_buttons = this.config.dialog.func_buttons;
        var size = func_buttons.length;
        var btn = null;
        var button = null;
        title.innerHTML = this.config.dialog.title;
        context.innerHTML = this.config.dialog.context;
        if(size <= 0)
        {
            btn_area.style.display = "none";
            if(!isNaN(txtHeight))
            {
                context.style.height = (txtHeight + 26) + "px";
            }
        }
        else
        {
            btn_area.style.display = "block";
            btn_link.innerHTML = "";
            for(var i = 0; i < size; i++)
            {
                btn = func_buttons[i];
                button = this.$dialog_create_func_btn(btn);
                this.parent.$A(button, btn_link);
                if(0 == i)
                {
                    this.config.dialog.$first_btn = button;
                }
            }
        }
    },
    /**
     * 重置对话框大小
     */
    $dialog_resize : function()
    {
        this.$ui_mask("dialog");
        this.$dialog_set_position();
    },
    /**
     * 设置对话框的位置
     */
    $dialog_set_position : function()
    {
        var dialog = this.parent.$E(this.prefix + this.config.dialog.id);
        if(dialog)
        {
            var viewport = this.parent.getViewportSize();
            var scroll = this.parent.getScrollPosition();
            var width = parseInt(this.config.dialog.width, 10);
            var height = parseInt(this.config.dialog.height, 10);
            var _w = isNaN(width) ? 0 : width;
            var _h = isNaN(height) ? 180 : height;
            var offsetLeft = viewport.width / 2 - _w / 2;
            var offsetTop = viewport.height / 2 - _h / 2 + scroll.top;
            dialog.style.left = offsetLeft + "px";
            dialog.style.top = offsetTop + "px";
        }
    },
    /**
     * 建立对话框
     */
    dialog : function(param)
    {
        this.$dialog_set((param || {}));
        this.$setDialogStyle();
        if(!this.$is_exist_dialog())
        {
            var frame = this.$dialog_create_frame();
            var titleBar = this.$dialog_create_titlebar();
            var op_buttons = this.$dialog_create_op_buttons();
            var body = this.$dialog_body();
            var bottom = this.$dialog_bottom();
            this.config.dialog.$dialog_win = this.$ui_mask("dialog");
            this.parent.$A(titleBar, frame);
            if(null != op_buttons)
            {
                this.parent.$A(op_buttons, frame);
            }
            this.parent.$A(body, frame);
            this.parent.$A(bottom, frame);
            this.parent.$A(frame.parentNode, this.config.dialog.$dialog_win);
        }
        this.$set_dialog_data();
        this.$dialog_set_position();
        this.dialog_show();
        if(null != this.config.dialog.$first_btn)
        {
            this.config.dialog.$first_btn.focus();
        }
        var _this = this;
        window.attachEvent("onresize", function(){
            _this.$dialog_resize();
        });
    }
};
